]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] Healthchecks: get a proper error code if connection cannot be completed immediately
authorKrzysztof Piotr Oledzki <ole@ans.pl>
Sat, 2 Jan 2010 21:03:01 +0000 (22:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Jan 2010 18:23:19 +0000 (19:23 +0100)
In case of a non-blocking socket, used for connecting to a remote
server (not localhost), the error reported by the health check
was most of a time one of EINPROGRESS/EAGAIN/EALREADY.

This patch adds a getsockopt(..., SO_ERROR, ...) call so now
the proper error message is reported.

src/checks.c

index 388efdf0249af982822d7ad175133a6c880b7917..b6f73bd305a4eb4f523331e7b7e89ee28fc4caf9 100644 (file)
@@ -651,7 +651,13 @@ static int event_srv_chk_w(int fd)
 
        //fprintf(stderr, "event_srv_chk_w, state=%ld\n", unlikely(fdtab[fd].state));
        if (unlikely(fdtab[fd].state == FD_STERROR || (fdtab[fd].ev & FD_POLL_ERR))) {
-               set_server_check_status(s, HCHK_STATUS_L4CON, strerror(errno));
+               int skerr, err = errno;
+               socklen_t lskerr = sizeof(skerr);
+
+               if (!getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr) && skerr)
+                       err = skerr;
+
+               set_server_check_status(s, HCHK_STATUS_L4CON, strerror(err));
                goto out_error;
        }