]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection: Make sure we have a mux before calling detach().
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 13 Apr 2018 13:50:27 +0000 (15:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Apr 2018 14:02:21 +0000 (16:02 +0200)
In some cases, we call cs_destroy() very early, so early the connection
doesn't yet have a mux, so we can't call mux->detach(). In this case,
just destroy the associated connection.

This should be backported to 1.8.

include/proto/connection.h

index bc8d88484c14ceedff398d99680548e7be9aadb0..8566736fd6a330e92631e3f9064ab701e70866fb 100644 (file)
@@ -699,7 +699,20 @@ static inline void conn_free(struct connection *conn)
 /* Release a conn_stream, and kill the connection if it was the last one */
 static inline void cs_destroy(struct conn_stream *cs)
 {
-       cs->conn->mux->detach(cs);
+       if (cs->conn->mux)
+               cs->conn->mux->detach(cs);
+       else {
+               /* It's too early to have a mux, let's just destroy
+                * the connection
+                */
+               struct connection *conn = cs->conn;
+
+               conn_stop_tracking(conn);
+               conn_full_close(conn);
+               if (conn->destroy_cb)
+                       conn->destroy_cb(conn);
+               conn_free(conn);
+       }
        cs_free(cs);
 }