From: Willy Tarreau Date: Mon, 18 May 2026 15:07:20 +0000 (+0200) Subject: BUG/MINOR: check: properly report errno in chk_report_conn_err() X-Git-Tag: v3.4-dev13~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b825d2745574ae4430ff385f5ae801ceec784e1;p=thirdparty%2Fhaproxy.git BUG/MINOR: check: properly report errno in chk_report_conn_err() When in 2.2, with commit c8dc20a825 ("BUG/MINOR: checks: refine which errno values are really errors."), errno reporting was refined, an extra check was added before calling retrieve_errno_from_socket(), and by mistake the test on !errno got inverted so that we only call the function to retrieve the error from the socket when errno is set! The first test in the function detects it and returns without changing anything, so this didn't have much effect, however when errno is not set (certain call places purposely pass zero so that getsockopt() is used), this wasn't called so the error wasn't reported. Apparently it only happened when called from process_chk_conn() after an async error was detected, so probably just cases where POLLERR is reported, which remains infrequent. Let's fix the direction of this flag. It can be backported if needed but it's unlikely anyone really noticed. --- diff --git a/src/check.c b/src/check.c index 077956559..01c3d2132 100644 --- a/src/check.c +++ b/src/check.c @@ -812,7 +812,7 @@ void chk_report_conn_err(struct check *check, int errno_bck, int expired) } errno = unclean_errno(errno_bck); - if (conn && errno) + if (conn && !errno) retrieve_errno_from_socket(conn); TRACE_ENTER(CHK_EV_HCHK_END|CHK_EV_HCHK_ERR, check, 0, 0, (size_t[]){expired});