MINOR: backend: compare conn hash for session conn reuse
Compare the connection hash when reusing a connection from the session.
This ensures that a private connection is reused only if it shares the
same set of parameters.
diff --git a/include/haproxy/session.h b/include/haproxy/session.h
index 6c20140..942111e 100644
--- a/include/haproxy/session.h
+++ b/include/haproxy/session.h
@@ -200,7 +200,7 @@
* list of the session <sess>. It returns a connection if found. Otherwise it
* returns NULL.
*/
-static inline struct connection *session_get_conn(struct session *sess, void *target)
+static inline struct connection *session_get_conn(struct session *sess, void *target, int64_t hash)
{
struct connection *srv_conn = NULL;
struct sess_srv_list *srv_list;
@@ -208,7 +208,9 @@
list_for_each_entry(srv_list, &sess->srv_list, srv_list) {
if (srv_list->target == target) {
list_for_each_entry(srv_conn, &srv_list->conn_list, session_list) {
- if (srv_conn->mux && (srv_conn->mux->avail_streams(srv_conn) > 0) &&
+ if (srv_conn->hash == hash &&
+ srv_conn->mux &&
+ (srv_conn->mux->avail_streams(srv_conn) > 0) &&
!(srv_conn->flags & CO_FL_WAIT_XPRT)) {
if (srv_conn->flags & CO_FL_SESS_IDLE) {
srv_conn->flags &= ~CO_FL_SESS_IDLE;
diff --git a/src/backend.c b/src/backend.c
index 4879940..fed177c 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1268,7 +1268,7 @@
goto skip_reuse;
/* first, search for a matching connection in the session's idle conns */
- srv_conn = session_get_conn(s->sess, s->target);
+ srv_conn = session_get_conn(s->sess, s->target, hash);
if (srv_conn)
reuse = 1;