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.
This commit is contained in:
Amaury Denoyelle 2022-03-29 18:36:59 +02:00
parent 50742294f5
commit dccbd733f0
3 changed files with 14 additions and 14 deletions

View 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);

View File

@ -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)

View 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);
}