From: Willy Tarreau Date: Thu, 4 Oct 2012 18:17:13 +0000 (+0200) Subject: MINOR: raw_sock: always report asynchronous connection errors X-Git-Tag: v1.5-dev13~223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0e98868fe08772260490f0381417a5636968b66;p=thirdparty%2Fhaproxy.git MINOR: raw_sock: always report asynchronous connection errors 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 ! --- diff --git a/src/raw_sock.c b/src/raw_sock.c index 37bea724b1..c417d5a7d3 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -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. */