]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes: Don't expect to have a mux without connection in destroy callback
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 14 Apr 2022 09:08:26 +0000 (11:08 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 14 Apr 2022 09:57:05 +0000 (11:57 +0200)
Once a mux initialized, the underlying connection alwaus exists from its
point of view and it is never removed until the mux is released. It may be
owned by another mux during an upgrade. But the pointer remains set. Thus
there is no reason to test it in the destroy callback function.

This patch should fix the issue #1652.

src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c

index 56a9a0bd012ee0b64cee414ed417ddd809d78760..cdb118c3a17b100fe379124656485d83ab459e51 100644 (file)
@@ -3576,7 +3576,7 @@ static void fcgi_destroy(void *ctx)
        struct fcgi_conn *fconn = ctx;
 
        TRACE_POINT(FCGI_EV_FCONN_END, fconn->conn);
-       if (eb_is_empty(&fconn->streams_by_id) || !fconn->conn || fconn->conn->ctx != fconn)
+       if (eb_is_empty(&fconn->streams_by_id) || fconn->conn->ctx != fconn)
                fcgi_release(fconn);
 }
 
index 12769d95b14e5665c7b87aa77ff1aaade7b88e17..fb4cd28f420733fc707a94837eba397f81adee16 100644 (file)
@@ -3337,7 +3337,7 @@ static void h1_destroy(void *ctx)
        struct h1c *h1c = ctx;
 
        TRACE_POINT(H1_EV_H1C_END, h1c->conn);
-       if (!h1c->h1s || !h1c->conn || h1c->conn->ctx != h1c)
+       if (!h1c->h1s || h1c->conn->ctx != h1c)
                h1_release(h1c);
 }
 
index af312c1a3506f9adf1cbb45a83a2c2dde1fe2171..d73e0cf440fad5be3a98198d67841296d398741b 100644 (file)
@@ -4350,7 +4350,7 @@ static void h2_destroy(void *ctx)
        struct h2c *h2c = ctx;
 
        TRACE_ENTER(H2_EV_H2C_END, h2c->conn);
-       if (eb_is_empty(&h2c->streams_by_id) || !h2c->conn || h2c->conn->ctx != h2c)
+       if (eb_is_empty(&h2c->streams_by_id) || h2c->conn->ctx != h2c)
                h2_release(h2c);
        TRACE_LEAVE(H2_EV_H2C_END);
 }
index 0c36c794ed3335ca864e0ac63d88316b8b41b32b..5c01ae54837b24653f54a8a22a39c207eda2536f 100644 (file)
@@ -413,9 +413,10 @@ static void mux_pt_destroy_meth(void *ctx)
        struct mux_pt_ctx *pt = ctx;
 
        TRACE_POINT(PT_EV_CONN_END, pt->conn, pt->cs);
-       if ((pt->endp->flags & CS_EP_ORPHAN) || !(pt->conn) || pt->conn->ctx != pt) {
-               if (pt->conn->ctx != pt)
+       if ((pt->endp->flags & CS_EP_ORPHAN) || pt->conn->ctx != pt) {
+               if (pt->conn->ctx != pt) {
                        pt->endp = NULL;
+               }
                mux_pt_destroy(pt);
        }
 }