From 15979619c410fd0e4638d935360c22eef8e8ce39 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 2 Jul 2020 15:56:23 +0200 Subject: [PATCH] MINOR: session: Take care to decrement idle_conns counter in session_unown_conn So conn_free() only calls session_unown_conn() if necessary. The details are now fully handled by session_unown_conn(). --- include/haproxy/connection.h | 5 +---- include/haproxy/session.h | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index 8ccb31d38e..094e54cde1 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -463,10 +463,7 @@ static inline void conn_free(struct connection *conn) { /* Remove ourself from the session's connections list, if any. */ if (!LIST_ISEMPTY(&conn->session_list)) { - struct session *sess = conn->owner; - if (conn->flags & CO_FL_SESS_IDLE) - sess->idle_conns--; - session_unown_conn(sess, conn); + session_unown_conn(conn->owner, conn); } sockaddr_free(&conn->src); diff --git a/include/haproxy/session.h b/include/haproxy/session.h index 5a46c4f5bb..05c56f6024 100644 --- a/include/haproxy/session.h +++ b/include/haproxy/session.h @@ -77,6 +77,9 @@ static inline void session_store_counters(struct session *sess) static inline void session_unown_conn(struct session *sess, struct connection *conn) { struct sess_srv_list *srv_list = NULL; + + if (conn->flags & CO_FL_SESS_IDLE) + sess->idle_conns--; LIST_DEL(&conn->session_list); LIST_INIT(&conn->session_list); list_for_each_entry(srv_list, &sess->srv_list, srv_list) { -- 2.47.3