[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)
This commit is contained in:
parent
f22b5d69da
commit
0528e2e712
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue