It goes like this:<br><br>static void ngx_http_upstream_check_broken_connection(...) {<br>     ...<br>    n = recv(c->fd, buf, 1, MSG_PEEK);<br>     ...<br>}<br><br>Checking for closed connection with recv(..., MSG_PEEK) is broken.<br>

<br>SSL closes are not 
detected, thus sockets stay in CLOSE_WAIT state forever -- nice DoS).<br>The alternative is to use stunnel with the X-Forwarded-For patch, but that's way too messy.<br><br>In
 ngx_http_upstream_check_broken_connection(), there seems to be a 
different path for kqueue.<br>What about modifying the poll/epoll behavior 
to detect disconnections for other event modules ?<br>In 
ngx_epoll_add_connection(), we can add the EPOLLHUP event, and mark the 
connection<br>as disconnected when processing HUP events instead of using 
the buggy MSG_PEEK hack.<br><br>What do you think ?<br><br>Nico.<br>