From: Amaury Denoyelle Date: Tue, 29 Mar 2022 16:36:59 +0000 (+0200) Subject: MINOR: mux-quic: reorganize qcs free X-Git-Tag: v2.6-dev5~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dccbd733f0bdbc66904b61c284cc375e08ed8a1d;p=thirdparty%2Fhaproxy.git 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 26d9250f7c..1adbfcad5c 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -12,7 +12,7 @@ #include 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 711ba23e6d..463c1318ad 100644 --- 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) diff --git a/src/mux_quic.c b/src/mux_quic.c index 696dc8f20e..8381a817b1 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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); }