From 0528e2e71292291e179f5cda2b7ab8aba2d6c7d1 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Mon, 9 Oct 2017 00:41:45 -0400 Subject: [PATCH] [core] limit use of TCP_CORK limit use of TCP_CORK to when chunkqueue contains a non-MEM_CHUNK (in addition to restricting to Linux, more than one chunk, and TCP) --- src/connections-glue.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/connections-glue.c b/src/connections-glue.c index 171a36b9..8ba37c34 100644 --- a/src/connections-glue.c +++ b/src/connections-glue.c @@ -320,14 +320,19 @@ int connection_write_chunkqueue(server *srv, connection *con, chunkqueue *cq, of written = cq->bytes_out; #ifdef TCP_CORK - /* Linux: put a cork into the socket as we want to combine the write() calls - * but only if we really have multiple chunks, and only if TCP socket + /* Linux: put a cork into socket as we want to combine write() calls + * but only if we really have multiple chunks including non-MEM_CHUNK, + * and only if TCP socket */ if (cq->first && cq->first->next) { const int sa_family = con->srv_socket->addr.plain.sa_family; if (sa_family == AF_INET || sa_family == AF_INET6) { - corked = 1; - (void)setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked)); + chunk *c = cq->first; + while (c->type == MEM_CHUNK && NULL != (c = c->next)) ; + if (NULL != c) { + corked = 1; + (void)setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked)); + } } } #endif -- 2.11.4.GIT