0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-15 09:31:46 +02:00

ircd::resource::method: Add method flag to cork response.

This commit is contained in:
Jason Volk 2023-03-02 18:42:19 -08:00
parent 0907fa08e3
commit 371c50cfcc
2 changed files with 17 additions and 0 deletions

View file

@ -65,6 +65,9 @@ enum ircd::resource::method::flag
/// This option prevents TCP nodelay from being toggled at the end of the
/// request to flush the sendq; TCP delays are used by default.
RESPONSE_NOFLUSH = 0x0008,
/// This option TCP corks the response during the request.
RESPONSE_NOPUSH = 0x0010,
};
struct ircd::resource::method::opts

View file

@ -603,6 +603,13 @@ try
tokens(client.request.params, '/', client.request.param)
};
// Start the TCP cork if the method has this option set.
if(opts->flags & RESPONSE_NOPUSH)
{
assert(client.sock);
net::nopush(*client.sock, true);
}
// Finally handle the request.
const auto &ret
{
@ -612,6 +619,13 @@ try
// Increment the successful completion counter for the handler.
++stats->completions;
// Stop the TCP cork if the method has this option set.
if(opts->flags & RESPONSE_NOPUSH)
{
assert(client.sock);
net::nopush(*client.sock, false);
}
// 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