0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 04:38:52 +02:00

ircd: Add client request timer related.

This commit is contained in:
Jason Volk 2017-09-23 19:46:17 -07:00
parent befb76a9d9
commit 7f7ef9a4bf
3 changed files with 12 additions and 7 deletions

View file

@ -56,6 +56,7 @@ struct ircd::client
unique_const_iterator<list> clit;
std::shared_ptr<socket> sock;
ircd::timer request_timer;
bool main() noexcept;

View file

@ -232,6 +232,7 @@ ircd::client::client(const host_port &host_port,
ircd::client::client(std::shared_ptr<socket> sock)
:clit{clients, clients.emplace(end(clients), this)}
,sock{std::move(sock)}
,request_timer{ircd::timer::stopped}
{
}
@ -310,6 +311,7 @@ ircd::handle_request(client &client,
parse::capstan &pc)
try
{
client.request_timer = ircd::timer{};
client.sock->set_timeout(request_timeout, [&client]
(const error_code &ec)
{
@ -331,9 +333,10 @@ try
}
catch(const http::error &e)
{
log::debug("client[%s] HTTP %s %s",
log::debug("client[%s] HTTP %s in %ld$us %s",
string(remote_addr(client)),
e.what(),
client.request_timer.at<microseconds>().count(),
e.content);
switch(e.code)

View file

@ -359,13 +359,14 @@ ircd::resource::response::response(client &client,
}
};
log::debug("client[%s] HTTP %d %s (%s) content-length: %zu %s...",
log::debug("client[%s] HTTP %d %s in %ld$us (%s) content-length: %zu %s...",
string(remote_addr(client)),
int(code),
http::reason[code],
content_type,
str.size(),
startswith(content_type, "text") ||
content_type == "application/json" ||
content_type == "application/javascript"? str.substr(0, 96) : string_view{});
client.request_timer.at<microseconds>().count(),
content_type,
str.size(),
startswith(content_type, "text") ||
content_type == "application/json" ||
content_type == "application/javascript"? str.substr(0, 96) : string_view{});
}