Changes between Initial Version and Version 1 of Ticket #320


Ignore:
Timestamp:
03/15/13 13:40:44 (9 years ago)
Author:
Maxim Dounin
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #320 – Description

    initial v1  
    1 recv(MSG_PEEK) is the generic way to test when connection was closed.
    2 This works on all platforms, except with pending data.
     1To detect if a connection was closed by a client, nginx uses:
    32
    4 It is not possible to reliably detect with standard socket interface
    5 if the client connection was closed with pending data. This covers:
    6 - ssl connection
    7 - pipelined request
     3- A EV_EOF flag as reported by kqueue.  This only works if you use kqueue, i.e. on FreeBSD and friends.
    84
    9 This results in that nginx doesn't drop backend proxy_pass connection
    10 and sockets stay in CLOSE_WAIT state forever.
    11 (It was reported that time can be reduced with proxy_read_timeout.)
     5- The recv(MSG_PEEK) call to test a case when connection was closed.  This works on all platforms, but only if there are no pending data.
    126
    13 To solve this, a hint could be used to indicate EOF event such as:
    14 1) SSL_peek() for https.  But that doesn't cover http.
    15 2) OS-provided filter-specific EOF condition on every supported platform:
    16 - BSD kqueue EV_EOF (already present)
    17 - Linux epoll
    18 - ...
     7Most notably, this doesn't cover Linux and SSL connections, which are usually closed with pending data (a shutdown alert). To improve things, the following should be implemented (in no particular order):
     8
     9- SSL_peek() for SSL connections instead of recv(MSG_PEEK), likely with additional c->peek() call.
     10- Support for EPOLLRDHUP, which is believed to be close to EV_EOF provided by kqueue.
    1911
    2012References: