From: Olivier Houchard Date: Wed, 29 Jul 2026 22:59:04 +0000 (+0200) Subject: MEDIUM: server: Do not close other thread groups' connections at deinit X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=5ce5a3638255678e63a0109062f65c0bca7c6508;p=thirdparty%2Fhaproxy.git MEDIUM: server: Do not close other thread groups' connections at deinit srv_close_idle_conns() runs at deinit, on the last remaining thread, and closes the FDs of every thread's idle connections. With per-thread-group FD tables, the connections of the other thread groups were already closed by the kernel when the last thread of their group exited, and their numbers are only meaningful in those groups' tables, closing them from here would in fact close whatever FD carries the same number in this thread's own table, and let sock_conn_ctrl_close() rewrite an unrelated entry of this group's FD table. So in that case, only release the memory and leave the FDs alone. --- diff --git a/src/server.c b/src/server.c index ad7734c00..348679537 100644 --- a/src/server.c +++ b/src/server.c @@ -7794,7 +7794,15 @@ static void srv_close_idle_conns(struct server *srv) for (cleaned_tree = conn_trees; *cleaned_tree; ++cleaned_tree) { while ((conn = ceb64_item_first(*cleaned_tree, hash_node.node, hash_node.key, struct connection))) { - if (conn->ctrl->ctrl_close) + /* + * Make sure we only close our own fds. If the + * connection was owned by another thread group, + * it should be closed already as all those + * threads exited already. + */ + if (conn->ctrl->ctrl_close && + (!(global.tune.options & GTUNE_NO_TG_FD_SHARING) || + ha_thread_info[i].tgid == tgid)) conn->ctrl->ctrl_close(conn); conn_delete_from_tree(conn, i); }