MINOR: mux-quic: reorganize qcs free
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.
diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h
index 26d9250..1adbfca 100644
--- a/include/haproxy/mux_quic.h
+++ b/include/haproxy/mux_quic.h
@@ -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);
diff --git a/src/h3.c b/src/h3.c
index 711ba23..463c131 100644
--- a/src/h3.c
+++ b/src/h3.c
@@ -840,7 +840,7 @@
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)
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 696dc8f..8381a81 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -137,11 +137,19 @@
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 @@
}
}
- 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);
}