]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: raw_sock: always report asynchronous connection errors
authorWilly Tarreau <w@1wt.eu>
Thu, 4 Oct 2012 18:17:13 +0000 (20:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 4 Oct 2012 20:26:09 +0000 (22:26 +0200)
Depending on the pollers used, a connection error may be notified
with POLLOUT|POLLERR|POLLHUP. POLLHUP by itself is enough for the
connection handler to call the read actor, which would only consider
this flag as a good indication of a hangup, without considering the
POLLERR flag.

In order to address this, we directly jump to the read0 label if
POLLERR was not set.

This will be important with health checks as we don't want to believe
a connection was properly established when it's not the case !

src/raw_sock.c

index 37bea724b151053c6b1f73a75427c5ef93b53486..c417d5a7d3f066d26a1ee340f84a2e5c8d7b20b1 100644 (file)
@@ -70,7 +70,7 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int co
         * Since older splice() implementations were buggy and returned
         * EAGAIN on end of read, let's bypass the call to splice() now.
         */
-       if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_IN|FD_POLL_HUP)) == FD_POLL_HUP)
+       if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_IN|FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
                goto out_read0;
 
        while (count) {
@@ -202,7 +202,7 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
        int try = count;
 
        /* stop here if we reached the end of data */
-       if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_IN|FD_POLL_HUP)) == FD_POLL_HUP)
+       if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_IN|FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
                goto read0;
 
        /* compute the maximum block size we can read at once. */