mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
[BUG] Healthchecks: get a proper error code if connection cannot be completed immediately
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.
This commit is contained in:
parent
a9679ac94b
commit
6492db5453
@ -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));
|
//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))) {
|
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;
|
goto out_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user