From fb05edec78dc1d05af73268fb6b51a4a9d090075 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 16 Jun 2025 16:33:04 +0200 Subject: [PATCH] BUG/MEDIUM: check: Set SOCKERR by default when a connection error is reported When a connection error is reported, we try to collect as much information as possible on the connection status and the server status is adjusted accordingly. However, the function does nothing if there is no connection error and if the healthcheck is not expired yet. It is a problem when an internal error occurred. It may happen at many places and it is hard to be sure an error is reported on the connection. And in fact, it is already a problem when the multiplexer allocation fails. In that case, the healthcheck is not interrupted as it should be. Concretely, it could only happen when a connection is established. It is hard to predict the effects of this bug. It may be unimportant. But it could probably lead to a crash. To avoid any issue, a SOCKERR status is now set by default when a connection error is reported. There is no reason to report a connection error for nothing. So a healthcheck failure must be reported. There is no "internal error" status. So a socket error is reported. This patch must be backport to all stable versions. (cherry picked from commit 54d74259e9860c7017903221f27525be89983a75) Signed-off-by: Christopher Faulet (cherry picked from commit 18542f3a8b2c42598ca1e5061507c8393bc3ce2d) Signed-off-by: Christopher Faulet (cherry picked from commit 806f245ea838066ca32a6a2bb1118f90c17f1597) Signed-off-by: Christopher Faulet --- src/check.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/check.c b/src/check.c index dc62d7a..415be90 100644 --- a/src/check.c +++ b/src/check.c @@ -823,9 +823,6 @@ void chk_report_conn_err(struct check *check, int errno_bck, int expired) if (conn && errno) retrieve_errno_from_socket(conn); - if (conn && !(conn->flags & CO_FL_ERROR) && !sc_ep_test(sc, SE_FL_ERROR) && !expired) - return; - TRACE_ENTER(CHK_EV_HCHK_END|CHK_EV_HCHK_ERR, check, 0, 0, (size_t[]){expired}); /* we'll try to build a meaningful error message depending on the @@ -978,6 +975,11 @@ void chk_report_conn_err(struct check *check, int errno_bck, int expired) set_server_check_status(check, tout, err_msg); } + if (check->result == CHK_RES_UNKNOWN) { + /* No other reason found, report a socket error (may be an internal or a ressournce error) */ + set_server_check_status(check, HCHK_STATUS_SOCKERR, err_msg); + } + TRACE_LEAVE(CHK_EV_HCHK_END|CHK_EV_HCHK_ERR, check); return; } -- 1.7.10.4