]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: raw_sock: also consider ENOTCONN in addition to EAGAIN for recv()
authorJoshua M. Clulow <josh@sysmgr.org>
Mon, 3 Mar 2014 21:48:42 +0000 (13:48 -0800)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Mar 2014 06:27:18 +0000 (07:27 +0100)
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.

src/raw_sock.c

index 3708b19847651cb5e13db7bc6ef758655b065175..c093377cfa89c74167b21a359f44b5f0ab51ad99 100644 (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;
                }