Skip to content

Commit fa1a168

Browse files
committed
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.
1 parent 67df657 commit fa1a168

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/session.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ int session_add_conn(struct session *sess, struct connection *conn)
705705
*/
706706
int session_check_idle_conn(struct session *sess, struct connection *conn)
707707
{
708+
struct server *srv = objt_server(conn->target);
709+
708710
/* Connection must be attached to session prior to this function call. */
709711
BUG_ON(!conn->owner || conn->owner != sess);
710712

@@ -715,7 +717,8 @@ int session_check_idle_conn(struct session *sess, struct connection *conn)
715717
/* Ensure conn is not already accounted as idle to prevent sess idle count excess increment. */
716718
BUG_ON(conn->flags & CO_FL_SESS_IDLE);
717719

718-
if (sess->idle_conns >= sess->fe->max_out_conns) {
720+
if (sess->idle_conns >= sess->fe->max_out_conns ||
721+
(srv && (srv->cur_admin & SRV_ADMF_MAINT))) {
719722
session_unown_conn(sess, conn);
720723
conn->owner = NULL;
721724
return -1;

0 commit comments

Comments
 (0)