From: Amaury Denoyelle Date: Fri, 25 Oct 2024 14:26:12 +0000 (+0200) Subject: MINOR: quic_pacing: define frms list and use it for MUX STREAM emission X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d0a24a2d964640391c2a5ae913b6beee96d762b;p=thirdparty%2Fhaproxy.git MINOR: quic_pacing: define frms list and use it for MUX STREAM emission --- diff --git a/include/haproxy/quic_pacing-t.h b/include/haproxy/quic_pacing-t.h index fd30745715..220066994b 100644 --- a/include/haproxy/quic_pacing-t.h +++ b/include/haproxy/quic_pacing-t.h @@ -1,9 +1,11 @@ #ifndef _HAPROXY_QUIC_PACING_T_H #define _HAPROXY_QUIC_PACING_T_H +#include #include struct quic_pacer { + struct list frms; const struct quic_cc_path *path; }; diff --git a/include/haproxy/quic_pacing.h b/include/haproxy/quic_pacing.h index eff7315988..f58c3a3402 100644 --- a/include/haproxy/quic_pacing.h +++ b/include/haproxy/quic_pacing.h @@ -3,10 +3,30 @@ #include +#include +#include + static inline void quic_pacing_init(struct quic_pacer *pacer, const struct quic_cc_path *path) { + LIST_INIT(&pacer->frms); pacer->path = path; } +static inline void quic_pacing_reset(struct quic_pacer *pacer) +{ + struct quic_frame *frm; + + while (!LIST_ISEMPTY(&pacer->frms)) { + frm = LIST_ELEM(pacer->frms.n, struct quic_frame *, list); + /* qc_frm_free is responsible to detach frm from pacer list. */ + qc_frm_free(NULL, &frm); + } +} + +static inline struct list *quic_pacing_frms(struct quic_pacer *pacer) +{ + return &pacer->frms; +} + #endif /* _HAPROXY_QUIC_PACING_H */ diff --git a/src/mux_quic.c b/src/mux_quic.c index 7b3f705e76..05cfa31635 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2244,8 +2245,8 @@ static int qcs_send(struct qcs *qcs, struct list *frms, uint64_t window_conn) */ static int qcc_io_send(struct qcc *qcc) { - struct list frms = LIST_HEAD_INIT(frms); /* Temporary list for QCS on error. */ + struct list *frms = quic_pacing_frms(&qcc->tx.pacer); struct list qcs_failed = LIST_HEAD_INIT(qcs_failed); struct qcs *qcs, *qcs_tmp, *first_qcs = NULL; uint64_t window_conn = qfctl_rcap(&qcc->tx.fc); @@ -2338,7 +2339,7 @@ static int qcc_io_send(struct qcc *qcc) if (!qfctl_rblocked(&qcc->tx.fc) && !qfctl_rblocked(&qcs->tx.fc) && window_conn > total) { - if ((ret = qcs_send(qcs, &frms, window_conn - total)) < 0) { + if ((ret = qcs_send(qcs, frms, window_conn - total)) < 0) { /* Temporarily remove QCS from send-list. */ LIST_DEL_INIT(&qcs->el_send); LIST_APPEND(&qcs_failed, &qcs->el_send); @@ -2362,7 +2363,7 @@ static int qcc_io_send(struct qcc *qcc) /* Retry sending until no frame to send, data rejected or connection * flow-control limit reached. */ - while (qcc_send_frames(qcc, &frms) == 0 && !qfctl_rblocked(&qcc->tx.fc)) { + while ((ret = qcc_send_frames(qcc, frms)) == 0 && !qfctl_rblocked(&qcc->tx.fc)) { window_conn = qfctl_rcap(&qcc->tx.fc); resent = 0; @@ -2380,7 +2381,7 @@ static int qcc_io_send(struct qcc *qcc) BUG_ON(resent > window_conn); if (!qfctl_rblocked(&qcs->tx.fc) && window_conn > resent) { - if ((ret = qcs_send(qcs, &frms, window_conn - resent)) < 0) { + if ((ret = qcs_send(qcs, frms, window_conn - resent)) < 0) { LIST_DEL_INIT(&qcs->el_send); LIST_APPEND(&qcs_failed, &qcs->el_send); continue; @@ -2394,12 +2395,7 @@ static int qcc_io_send(struct qcc *qcc) sent_done: /* Deallocate frames that the transport layer has rejected. */ - if (!LIST_ISEMPTY(&frms)) { - struct quic_frame *frm, *frm2; - - list_for_each_entry_safe(frm, frm2, &frms, list) - qc_frm_free(qcc->conn->handle.qc, &frm); - } + quic_pacing_reset(&qcc->tx.pacer); /* Re-insert on-error QCS at the end of the send-list. */ if (!LIST_ISEMPTY(&qcs_failed)) { @@ -2719,6 +2715,8 @@ static void qcc_release(struct qcc *qcc) qc_frm_free(qcc->conn->handle.qc, &frm); } + quic_pacing_reset(&qcc->tx.pacer); + if (qcc->app_ops && qcc->app_ops->release) qcc->app_ops->release(qcc->ctx); TRACE_PROTO("application layer released", QMUX_EV_QCC_END, conn);