From: Willy Tarreau Date: Sun, 8 Oct 2017 09:26:30 +0000 (+0200) Subject: MEDIUM: session: make use of the connection's destroy callback X-Git-Tag: v1.8-rc1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e13cbafe2612dc026494d90ce8604f08cdaf58d;p=thirdparty%2Fhaproxy.git 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 cbc8a5ebdc..dc97544546 100644 --- a/src/session.c +++ b/src/session.c @@ -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: diff --git a/src/stream.c b/src/stream.c index b1c2b04f94..ddaca39260 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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)) {