From: Amaury Denoyelle Date: Thu, 21 Aug 2025 16:42:50 +0000 (+0200) Subject: MEDIUM: session: close new idle conns if server in maintenance X-Git-Tag: v3.3-dev8~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fa1a168bf16ad8926775478bde8819efb4b8502a;p=thirdparty%2Fhaproxy.git MEDIUM: session: close new idle conns if server in maintenance Previous patch ensures that a backend connection going into idle state is rejected and freed if its target server is in maintenance. This patch introduces a similar change for connections attached in the session. session_check_idle_conn() now returns an errorl if connection target server is in maintenance, similarly to session max idle conns limit reached. This is sufficient to instruct muxes to delete the connection immediately. --- diff --git a/src/session.c b/src/session.c index 8f871f815..89f81fde8 100644 --- a/src/session.c +++ b/src/session.c @@ -705,6 +705,8 @@ int session_add_conn(struct session *sess, struct connection *conn) */ int session_check_idle_conn(struct session *sess, struct connection *conn) { + struct server *srv = objt_server(conn->target); + /* Connection must be attached to session prior to this function call. */ BUG_ON(!conn->owner || conn->owner != sess); @@ -715,7 +717,8 @@ int session_check_idle_conn(struct session *sess, struct connection *conn) /* Ensure conn is not already accounted as idle to prevent sess idle count excess increment. */ BUG_ON(conn->flags & CO_FL_SESS_IDLE); - if (sess->idle_conns >= sess->fe->max_out_conns) { + if (sess->idle_conns >= sess->fe->max_out_conns || + (srv && (srv->cur_admin & SRV_ADMF_MAINT))) { session_unown_conn(sess, conn); conn->owner = NULL; return -1;