diff --git a/include/ircd/resource/method.h b/include/ircd/resource/method.h index 4139e7c86..caa1fe0d0 100644 --- a/include/ircd/resource/method.h +++ b/include/ircd/resource/method.h @@ -50,6 +50,7 @@ enum ircd::resource::method::flag RATE_LIMITED = 0x02, VERIFY_ORIGIN = 0x04, //TODO: matrix abstraction bleed. CONTENT_DISCRETION = 0x08, + DELAYED_ACK = 0x10, }; struct ircd::resource::method::opts diff --git a/ircd/resource.cc b/ircd/resource.cc index f9343f7a0..e36210dc4 100644 --- a/ircd/resource.cc +++ b/ircd/resource.cc @@ -553,6 +553,17 @@ try 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) { // Copy any partial content to the final contiguous allocated buffer;