diff --git a/src/checks.c b/src/checks.c index 4d9883081..36df06f9b 100644 --- a/src/checks.c +++ b/src/checks.c @@ -435,16 +435,12 @@ static int event_srv_chk_r(int fd) int len; struct task *t = fdtab[fd].owner; struct server *s = t->context; - int skerr; - socklen_t lskerr = sizeof(skerr); len = -1; if (unlikely((s->result & SRV_CHK_ERROR) || (fdtab[fd].state == FD_STERROR) || - (fdtab[fd].ev & FD_POLL_ERR) || - (getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr) == -1) || - (skerr != 0))) { + (fdtab[fd].ev & FD_POLL_ERR))) { /* in case of TCP only, this tells us if the connection failed */ s->result |= SRV_CHK_ERROR; goto out_wakeup; @@ -455,10 +451,15 @@ static int event_srv_chk_r(int fd) * works correctly and we don't need to do the getsockopt() on linux. */ len = recv(fd, trash, sizeof(trash), 0); - if (unlikely(len < 0 && errno == EAGAIN)) { - /* we want some polling to happen first */ - fdtab[fd].ev &= ~FD_POLL_IN; - return 0; + if (unlikely(len < 0)) { + if (errno == EAGAIN) { + /* not ready, we want to poll first */ + fdtab[fd].ev &= ~FD_POLL_IN; + return 0; + } + /* network error, report it */ + s->result |= SRV_CHK_ERROR; + goto out_wakeup; } /* Note: the response will only be accepted if read at once */