mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-11 09:37:20 +02:00
MEDIUM: raw_sock: improve connection error reporting
When a connection setup is pending and we receive an error without a POLL_IN flag, we're certain there will be nothing to read from it and we can safely report an error without attempting a recv() call. This will be significantly better for health checks which will avoid a useless recv() on all failed checks.
This commit is contained in:
parent
c0e98868fe
commit
6f5d141149
@ -70,9 +70,18 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int co
|
|||||||
* Since older splice() implementations were buggy and returned
|
* Since older splice() implementations were buggy and returned
|
||||||
* EAGAIN on end of read, let's bypass the call to splice() now.
|
* 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_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
|
if (unlikely(!(fdtab[conn->t.sock.fd].ev & FD_POLL_IN))) {
|
||||||
|
/* stop here if we reached the end of data */
|
||||||
|
if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
|
||||||
goto out_read0;
|
goto out_read0;
|
||||||
|
|
||||||
|
/* report error on POLL_ERR before connection establishment */
|
||||||
|
if ((fdtab[conn->t.sock.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
|
||||||
|
conn->flags |= CO_FL_ERROR;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (count) {
|
while (count) {
|
||||||
if (count > MAX_SPLICE_AT_ONCE)
|
if (count > MAX_SPLICE_AT_ONCE)
|
||||||
count = MAX_SPLICE_AT_ONCE;
|
count = MAX_SPLICE_AT_ONCE;
|
||||||
@ -201,10 +210,18 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
|
|||||||
int ret, done = 0;
|
int ret, done = 0;
|
||||||
int try = count;
|
int try = count;
|
||||||
|
|
||||||
|
if (unlikely(!(fdtab[conn->t.sock.fd].ev & FD_POLL_IN))) {
|
||||||
/* stop here if we reached the end of data */
|
/* stop here if we reached the end of data */
|
||||||
if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_IN|FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
|
if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
|
||||||
goto read0;
|
goto read0;
|
||||||
|
|
||||||
|
/* report error on POLL_ERR before connection establishment */
|
||||||
|
if ((fdtab[conn->t.sock.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
|
||||||
|
conn->flags |= CO_FL_ERROR;
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* compute the maximum block size we can read at once. */
|
/* compute the maximum block size we can read at once. */
|
||||||
if (buffer_empty(buf)) {
|
if (buffer_empty(buf)) {
|
||||||
/* let's realign the buffer to optimize I/O */
|
/* let's realign the buffer to optimize I/O */
|
||||||
|
Loading…
Reference in New Issue
Block a user