]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sessions: Start to store the outgoing connection in sessions.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 13 Nov 2018 15:44:31 +0000 (16:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Nov 2018 20:44:56 +0000 (21:44 +0100)
Introduce a new field in session, "srv_conn", and a linked list of sessions
in the connection. It will be used later when we'll switch connections
from being managed by the stream, to being managed by the session.

include/proto/connection.h
include/types/connection.h
include/types/session.h
src/session.c

index 0b4a0d84520603725aa2e421b0b7511337857f47..ade69940114fbeea07af8a1059e39688e254dcf9 100644 (file)
@@ -558,6 +558,7 @@ static inline void conn_init(struct connection *conn)
        conn->destroy_cb = NULL;
        conn->proxy_netns = NULL;
        LIST_INIT(&conn->list);
+       LIST_INIT(&conn->session_list);
        conn->send_wait = NULL;
        conn->recv_wait = NULL;
 }
@@ -664,6 +665,13 @@ static inline void conn_force_unsubscribe(struct connection *conn)
 /* Releases a connection previously allocated by conn_new() */
 static inline void conn_free(struct connection *conn)
 {
+       struct session *sess, *sess_back;
+
+       list_for_each_entry_safe(sess, sess_back, &conn->session_list, conn_list) {
+               sess->srv_conn = NULL;
+               LIST_DEL(&sess->conn_list);
+               LIST_INIT(&sess->conn_list);
+       }
        conn_force_unsubscribe(conn);
        pool_free(pool_head_connection, conn);
 }
index 2ed39f69c770861d5f7b4c287ec87beb923cf00f..a85343bddaa706248c61e4594de24457c026883b 100644 (file)
@@ -408,6 +408,7 @@ struct connection {
        struct wait_event *send_wait; /* Task to wake when we're ready to send */
        struct wait_event *recv_wait; /* Task to wake when we're ready to recv */
        struct list list;             /* attach point to various connection lists (idle, ...) */
+       struct list session_list;     /* List of all sessions attached to this connection */
        int xprt_st;                  /* transport layer state, initialized to zero */
        int tmp_early_data;           /* 1st byte of early data, if any */
        int sent_early_data;          /* Amount of early data we sent so far */
index c3bace85c13bc4b25559b3fdb4ccc34706e14193..e0e1455640baa978c8646859a050c704fe91b704 100644 (file)
@@ -47,6 +47,8 @@ struct session {
        struct vars vars;               /* list of variables for the session scope. */
        struct task *task;              /* handshake timeout processing */
        long t_handshake;               /* handshake duration, -1 = not completed */
+       struct connection *srv_conn;    /* Server connection we last used */
+       struct list conn_list;          /* List element for the session list in each connection */
 };
 
 #endif /* _TYPES_SESSION_H */
index afab68add4cd47aad8903971ffc9a2c6bd2a1df1..d8c8d36cf086f54decf58b35b7e601f577d2b6ad 100644 (file)
@@ -53,6 +53,8 @@ struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type
                vars_init(&sess->vars, SCOPE_SESS);
                sess->task = NULL;
                sess->t_handshake = -1; /* handshake not done yet */
+               LIST_INIT(&sess->conn_list);
+               sess->srv_conn = NULL;
                HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.conn_max,
                                     HA_ATOMIC_ADD(&fe->feconn, 1));
                if (li)