mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd: Add client request timer related.
This commit is contained in:
parent
befb76a9d9
commit
7f7ef9a4bf
3 changed files with 12 additions and 7 deletions
|
@ -56,6 +56,7 @@ struct ircd::client
|
|||
|
||||
unique_const_iterator<list> clit;
|
||||
std::shared_ptr<socket> sock;
|
||||
ircd::timer request_timer;
|
||||
|
||||
bool main() noexcept;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -359,10 +359,11 @@ 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],
|
||||
client.request_timer.at<microseconds>().count(),
|
||||
content_type,
|
||||
str.size(),
|
||||
startswith(content_type, "text") ||
|
||||
|
|
Loading…
Reference in a new issue