summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-09-23 13:11:26 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-09-23 13:11:26 -0400
commitcbb5ee621cf754f03ae7805ce5afc9782fe539ea (patch)
treec03512138ea193e2ad3501cb698a631a17dc8bea
parent09b2b146e1ec44b2a7d1f407589e207bf2b176c4 (diff)
downloadlighttpd1.4-cbb5ee621cf754f03ae7805ce5afc9782fe539ea.tar.gz
lighttpd1.4-cbb5ee621cf754f03ae7805ce5afc9782fe539ea.zip
[core] disable Nagle if streaming to backend
disable Nagle algorithm if streaming to backend and content-length is unknown at the point where lighttpd is about to begin sending data to backend
-rw-r--r--src/gw_backend.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gw_backend.c b/src/gw_backend.c
index 0bc4939e..2cf63ccc 100644
--- a/src/gw_backend.c
+++ b/src/gw_backend.c
@@ -1796,6 +1796,16 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
if (HANDLER_GO_ON != rc) return rc;
}
+ /*(disable Nagle algorithm if streaming and content-length unknown)*/
+ if (AF_UNIX != hctx->host->family) {
+ connection *con = hctx->remote_conn;
+ if (-1 == con->request.content_length) {
+ if (-1 == fdevent_set_tcp_nodelay(hctx->fd, 1)) {
+ /*(error, but not critical)*/
+ }
+ }
+ }
+
fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN);
gw_set_state(srv, hctx, GW_STATE_WRITE);
/* fall through */