0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::resource: Add DELAYED_ACK flag to method; support TCP_QUICKACK opportunity.

This commit is contained in:
Jason Volk 2020-12-24 18:05:40 -08:00
parent a63fcfa5b4
commit 227ba21341
2 changed files with 12 additions and 0 deletions

View file

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

View file

@ -553,6 +553,17 @@ try
content_partial content_partial
}; };
// When we have incomplete content it's a good time to TCP_QUICKACK to
// coax the client into sending more as soon as possible. If we don't do
// this we risk waiting for our own kernel's delayed-acknowledgment timer
// in the subsequent reads for content below (or in the handler). We don't
// QUICKACK when we've received all content since we might be able to make
// an actual response all in one shot.
if(content_remain && ~opts->flags & DELAYED_ACK)
net::quickack(*client.sock, true);
// Branch taken to receive any remaining content in the common case where
// the resource handler does not perform its own consumption of content.
if(content_remain && ~opts->flags & CONTENT_DISCRETION) if(content_remain && ~opts->flags & CONTENT_DISCRETION)
{ {
// Copy any partial content to the final contiguous allocated buffer; // Copy any partial content to the final contiguous allocated buffer;