• Tollef Fog Heen's avatar
    Merge: r4046, r4047, r4183: Change the way we close client sessions. · 8503b3fb
    Tollef Fog Heen authored
    r4046:
    Change the way we close client sessions.
    
    Previously we always used SO_LINGER to make sure that all queued data
    got transmitted, no matter under which circumstances we closed the
    client connection.
    
    Change this so that SO_LINGER is only activated for orderly connection
    closure (ie: "Connection: close" from client or error handling), in
    all other cases (usually the client connecting on us, abandon any data
    queued for transmission.
    
    This _may_ reduce the tendency of worker threads to get hung up on
    network failures a little bit.
    
    r4047:
    r4046 forgot to reset SO_LINGER for pipe handling which basically
    broke pipehandling.
    
    Fixes #505
    
    r4183:
    Disable SO_LINGER when we time out a connection due to sess_timeout,
    so that we do not RST connections that have still not transmitted
    their
    data.
    
    Since we were able to get the writev(2) to detach the socket, we
    should
    not end up sleeping in the close(2) either.
    
    We still RST the socket for all error conditions.
    
    Ideally I would still like to RST connections that have no outstanding
    data after their sess_timeout, in order to avoid the 2*RTT+misc
    timeouts delays associated with loosing a TCP socket for a client
    that have gone to meet some other IP#.
    
    In particular with load-balancers, this allows the load balancer to
    declare the session dead right away, and reuse it for something more
    productive.
    
    Unfortunately, this lacks OS support in all presently released
    OS'es: you cannot ask if a socket is done transmitting what you
    asked it to.
    
    FreeBSD-8.0 will have experimental support for this (FIONWRITE)
    and I will revisit it in that context.
    
    
    git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@4248 d4fa192b-c00b-0410-8231-f00ffab90ce4
    8503b3fb
cache_acceptor_poll.c 4.17 KB