BUG/MINOR: raw_sock: also consider ENOTCONN in addition to EAGAIN for recv()

I was testing haproxy-1.5-dev22 on SmartOS (an illumos-based system)
and ran into a problem.  There's a small window after non-blocking
connect() is called, but before the TCP connection is established,
where recv() may return ENOTCONN.  On Linux, the behaviour here seems
to be always to return EAGAIN.  The fix is relatively trivial, and
appears to make haproxy work reliably on current SmartOS (see patch
below).  It's possible that other UNIX platforms exhibit this
behaviour as well.

Note: the equivalent was already done for send() in commit 0ea0cf6
("BUG: raw_sock: also consider ENOTCONN in addition to EAGAIN").
Both patches should be backported to 1.4.
This commit is contained in:
Joshua M. Clulow 2014-03-03 13:48:42 -08:00 committed by Willy Tarreau
parent 7640e72a31
commit 0724903143

View File

@ -309,7 +309,7 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
else if (ret == 0) {
goto read0;
}
else if (errno == EAGAIN) {
else if (errno == EAGAIN || errno == ENOTCONN) {
fd_cant_recv(conn->t.sock.fd);
break;
}