0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-03-17 06:50:23 +01:00

ircd::resource: Add TCP_NODELAY flush opportunity at completion boundary.

This commit is contained in:
Jason Volk 2020-12-25 00:10:14 -08:00
parent 227ba21341
commit 75a88976dc
2 changed files with 20 additions and 6 deletions

View file

@ -51,6 +51,7 @@ enum ircd::resource::method::flag
VERIFY_ORIGIN = 0x04, //TODO: matrix abstraction bleed.
CONTENT_DISCRETION = 0x08,
DELAYED_ACK = 0x10,
DELAYED_RESPONSE = 0x20,
};
struct ircd::resource::method::opts

View file

@ -606,13 +606,26 @@ try
tokens(client.request.params, '/', client.request.param)
};
const unwind_nominal completions{[this]
{
++stats->completions;
}};
// Finally handle the request.
return call_handler(client, client.request);
const auto &ret
{
call_handler(client, client.request)
};
// Increment the successful completion counter for the handler.
++stats->completions;
// This branch flips TCP_NODELAY to force transmission here. This is a
// good place because the request has finished writing everything; the
// socket doesn't know that, but we do, and this is the place. The action
// can be disabled by using the flag in the method's options.
if(likely(~opts->flags & DELAYED_RESPONSE))
{
assert(client.sock);
net::flush(*client.sock);
}
return ret;
}
catch(const http::error &e)
{