]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: reorganize qcs free
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 29 Mar 2022 16:36:59 +0000 (18:36 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 30 Mar 2022 14:12:18 +0000 (16:12 +0200)
Regroup some cleaning operations inside a new function qcs_free. This
can be used for all streams, both through qcs_destroy and with
uni-directional streams.

include/haproxy/mux_quic.h
src/h3.c
src/mux_quic.c

index 26d9250f7cad865b47fa13fd0a0b97f56d4f3955..1adbfcad5c022576791b190ed49e5c6b258c6394 100644 (file)
@@ -12,7 +12,7 @@
 #include <haproxy/xprt_quic-t.h>
 
 struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type);
-void uni_qcs_free(struct qcs *qcs);
+void qcs_free(struct qcs *qcs);
 
 struct buffer *qc_get_buf(struct qcs *qcs, struct buffer *bptr);
 
index 711ba23e6dba341dcbe56b9e9d0ec3152fdaf660..463c1318ada94c9cdcbbd51e5b656707b51c0409 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -840,7 +840,7 @@ static int h3_uqs_init(struct h3_uqs *h3_uqs, struct h3 *h3,
 static inline void h3_uqs_release(struct h3_uqs *h3_uqs)
 {
        if (h3_uqs->qcs)
-               uni_qcs_free(h3_uqs->qcs);
+               qcs_free(h3_uqs->qcs);
 }
 
 static inline void h3_uqs_release_all(struct h3 *h3)
index 696dc8f20e02c46c6492139333443b52745091ca..8381a817b1fc93e0befcc44b5a01c3b24655d6c1 100644 (file)
@@ -137,11 +137,19 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
        return qcs;
 }
 
-/* Free a qcs. This function must only be used for unidirectional streams.
- * Bidirectional streams are released by the upper layer through qc_detach().
+/* Free a qcs. This function must only be done to remove a stream on allocation
+ * error or connection shutdown. Else use qcs_destroy which handle all the
+ * QUIC connection mechanism.
  */
-void uni_qcs_free(struct qcs *qcs)
+void qcs_free(struct qcs *qcs)
 {
+       b_free(&qcs->rx.buf);
+       b_free(&qcs->tx.buf);
+       b_free(&qcs->tx.xprt_buf);
+
+       BUG_ON(!qcs->qcc->strms[qcs_id_type(qcs->by_id.key)].nb_streams);
+       --qcs->qcc->strms[qcs_id_type(qcs->by_id.key)].nb_streams;
+
        eb64_delete(&qcs->by_id);
        pool_free(pool_head_qcs, qcs);
 }
@@ -431,15 +439,7 @@ static void qcs_destroy(struct qcs *qcs)
                }
        }
 
-       eb64_delete(&qcs->by_id);
-
-       b_free(&qcs->rx.buf);
-       b_free(&qcs->tx.buf);
-       b_free(&qcs->tx.xprt_buf);
-
-       --qcs->qcc->strms[qcs_id_type(qcs->by_id.key)].nb_streams;
-
-       pool_free(pool_head_qcs, qcs);
+       qcs_free(qcs);
 
        TRACE_LEAVE(QMUX_EV_QCS_END, conn);
 }