]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: make use of the connection's destroy callback
authorWilly Tarreau <w@1wt.eu>
Sun, 8 Oct 2017 09:26:30 +0000 (11:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:03:24 +0000 (18:03 +0100)
Now we don't remove the session when a stream dies, instead we
detach the stream and let the mux decide to release the connection
and call session_free() instead.

src/session.c
src/stream.c

index cbc8a5ebdcfb80565d0a1888100abc37f4150b6c..dc9754454684024f3c3b8a454a37889c257f799a 100644 (file)
@@ -73,6 +73,14 @@ void session_free(struct session *sess)
        HA_ATOMIC_SUB(&jobs, 1);
 }
 
+/* callback used from the connection/mux layer to notify that a connection is
+ * gonig to be released.
+ */
+void conn_session_free(struct connection *conn)
+{
+       session_free(conn->owner);
+}
+
 /* perform minimal intializations, report 0 in case of error, 1 if OK. */
 int init_session()
 {
@@ -415,6 +423,9 @@ static int conn_complete_session(struct connection *conn)
                task_free(sess->task);
                sess->task = NULL;
        }
+
+       conn_set_owner(conn, sess, conn_session_free);
+
        return 0;
 
  fail:
index b1c2b04f94d48e5ec018eca06186fe20c6439cee..ddaca392608d478628e4e125ddefb5837a679a17 100644 (file)
@@ -394,7 +394,6 @@ static void stream_free(struct stream *s)
         * the stream must free the session.
         */
        pool_free2(pool2_stream, s);
-       session_free(sess);
 
        /* We may want to free the maximum amount of pools if the proxy is stopping */
        if (fe && unlikely(fe->state == PR_STSTOPPED)) {