Changeset 490

Show
Ignore:
Timestamp:
07/31/2005 11:02:57 AM (3 years ago)
Author:
jan
Message:

applied selective TCP_CORK from Christian von Roques (#97)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.3.x/src/network.c

    r320 r490  
    421421 
    422422int network_write_chunkqueue(server *srv, connection *con, chunkqueue *cq) { 
    423         int ret = -1, i; 
     423        int ret = -1; 
    424424        off_t written = 0; 
    425          
     425#ifdef TCP_CORK  
     426        int corked = 0; 
     427#endif 
    426428        server_socket *srv_socket = con->srv_socket; 
    427429 
     
    439441 
    440442#ifdef TCP_CORK  
    441         /* Linux: put a cork into the socket as we want to combine the write() calls */ 
    442         i = 1; 
    443         setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &i, sizeof(i)); 
     443        /* Linux: put a cork into the socket as we want to combine the write() calls 
     444         * but only if we really have multiple chunks 
     445         */ 
     446        if (cq->first && cq->first->next) { 
     447                corked = 1; 
     448                setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked)); 
     449        } 
    444450#endif 
    445451         
     
    477483                 
    478484                chunk *c, *pc = NULL; 
     485                int i; 
    479486                 
    480487                for (i = 0, c = cq->first; i < ret; i++, c = c->next) { 
     
    507514         
    508515#ifdef TCP_CORK 
    509         i = 0; 
    510         setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &i, sizeof(i)); 
     516        if (corked) { 
     517                corked = 0; 
     518                setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked)); 
     519        } 
    511520#endif 
    512521