]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: compare conn hash for session conn reuse
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 25 Jan 2021 09:29:35 +0000 (10:29 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Feb 2021 11:33:05 +0000 (12:33 +0100)
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.

include/haproxy/session.h
src/backend.c

index 6c2014048d2a6e1d77fa52d7fe81fbfb2bcb6f20..942111edbb31d9ba630efe747354cc45c722462a 100644 (file)
@@ -200,7 +200,7 @@ static inline int session_check_idle_conn(struct session *sess, struct connectio
  * 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 @@ static inline struct connection *session_get_conn(struct session *sess, void *ta
        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;
index 4879940ba2cbe077b71649505578fd9d995238c8..fed177c9bd4ead508b84f915fa711401b59925d9 100644 (file)
@@ -1268,7 +1268,7 @@ int connect_server(struct stream *s)
                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;