]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-quic: do not free conn if attached streams
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 27 Jul 2022 09:39:01 +0000 (11:39 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Aug 2022 12:23:19 +0000 (14:23 +0200)
Ensure via qcc_is_dead() that a connection is not released instance
until all of qcs streams are detached by the upper layer, even if an
error has been reported or the timeout has fired.

On the other side, as qc_detach() always check the connection status,
this should ensure that we do not keep a connection if not necessary.

Without this patch, a qcc instance may be freed with some of its qcs
streams not detached. This is an incorrect behavior and will lead to a
BUG_ON fault. Note however that no occurence of this bug has been
produced currently. This patch is mainly a safety against future
occurences.

This should be backported up to 2.6.

src/mux_quic.c

index 65d62a4aa815353bdabc3165fa4d54325058a863..3ab5333989dce96668d2f071628f8886e6715af0 100644 (file)
@@ -1001,7 +1001,12 @@ static void qcs_destroy(struct qcs *qcs)
 
 static inline int qcc_is_dead(const struct qcc *qcc)
 {
-       if ((qcc->conn->flags & CO_FL_ERROR) || !qcc->task)
+       /* Mux connection is considered dead if :
+        * - all stream-desc are detached AND
+        *   = connection is on error OR
+        *   = mux timeout has already fired or is unset
+        */
+       if (!qcc->nb_sc && ((qcc->conn->flags & CO_FL_ERROR) || !qcc->task))
                return 1;
 
        return 0;