MEDIUM: session: make use of the connection's destroy callback
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.
diff --git a/src/session.c b/src/session.c
index cbc8a5e..dc97544 100644
--- a/src/session.c
+++ b/src/session.c
@@ -73,6 +73,14 @@
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 @@
task_free(sess->task);
sess->task = NULL;
}
+
+ conn_set_owner(conn, sess, conn_session_free);
+
return 0;
fail:
diff --git a/src/stream.c b/src/stream.c
index b1c2b04..ddaca39 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -394,7 +394,6 @@
* 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)) {