MINOR: quic_pacing: define frms list and use it for MUX STREAM emission

This commit is contained in:
Amaury Denoyelle 2024-10-25 16:26:12 +02:00
parent 936ddf0be5
commit 340464adc6
3 changed files with 30 additions and 10 deletions

View File

@ -1,9 +1,11 @@
#ifndef _HAPROXY_QUIC_PACING_T_H #ifndef _HAPROXY_QUIC_PACING_T_H
#define _HAPROXY_QUIC_PACING_T_H #define _HAPROXY_QUIC_PACING_T_H
#include <haproxy/api-t.h>
#include <haproxy/quic_cc-t.h> #include <haproxy/quic_cc-t.h>
struct quic_pacer { struct quic_pacer {
struct list frms;
const struct quic_cc_path *path; const struct quic_cc_path *path;
}; };

View File

@ -3,10 +3,30 @@
#include <haproxy/quic_pacing-t.h> #include <haproxy/quic_pacing-t.h>
#include <haproxy/list.h>
#include <haproxy/quic_frame.h>
static inline void quic_pacing_init(struct quic_pacer *pacer, static inline void quic_pacing_init(struct quic_pacer *pacer,
const struct quic_cc_path *path) const struct quic_cc_path *path)
{ {
LIST_INIT(&pacer->frms);
pacer->path = path; 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 */ #endif /* _HAPROXY_QUIC_PACING_H */

View File

@ -19,6 +19,7 @@
#include <haproxy/quic_enc.h> #include <haproxy/quic_enc.h>
#include <haproxy/quic_fctl.h> #include <haproxy/quic_fctl.h>
#include <haproxy/quic_frame.h> #include <haproxy/quic_frame.h>
#include <haproxy/quic_pacing.h>
#include <haproxy/quic_sock.h> #include <haproxy/quic_sock.h>
#include <haproxy/quic_stream.h> #include <haproxy/quic_stream.h>
#include <haproxy/quic_tp-t.h> #include <haproxy/quic_tp-t.h>
@ -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) static int qcc_io_send(struct qcc *qcc)
{ {
struct list frms = LIST_HEAD_INIT(frms);
/* Temporary list for QCS on error. */ /* 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 list qcs_failed = LIST_HEAD_INIT(qcs_failed);
struct qcs *qcs, *qcs_tmp, *first_qcs = NULL; struct qcs *qcs, *qcs_tmp, *first_qcs = NULL;
uint64_t window_conn = qfctl_rcap(&qcc->tx.fc); 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) && if (!qfctl_rblocked(&qcc->tx.fc) &&
!qfctl_rblocked(&qcs->tx.fc) && window_conn > total) { !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. */ /* Temporarily remove QCS from send-list. */
LIST_DEL_INIT(&qcs->el_send); LIST_DEL_INIT(&qcs->el_send);
LIST_APPEND(&qcs_failed, &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 /* Retry sending until no frame to send, data rejected or connection
* flow-control limit reached. * 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); window_conn = qfctl_rcap(&qcc->tx.fc);
resent = 0; resent = 0;
@ -2380,7 +2381,7 @@ static int qcc_io_send(struct qcc *qcc)
BUG_ON(resent > window_conn); BUG_ON(resent > window_conn);
if (!qfctl_rblocked(&qcs->tx.fc) && window_conn > resent) { 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_DEL_INIT(&qcs->el_send);
LIST_APPEND(&qcs_failed, &qcs->el_send); LIST_APPEND(&qcs_failed, &qcs->el_send);
continue; continue;
@ -2394,12 +2395,7 @@ static int qcc_io_send(struct qcc *qcc)
sent_done: sent_done:
/* Deallocate frames that the transport layer has rejected. */ /* Deallocate frames that the transport layer has rejected. */
if (!LIST_ISEMPTY(&frms)) { quic_pacing_reset(&qcc->tx.pacer);
struct quic_frame *frm, *frm2;
list_for_each_entry_safe(frm, frm2, &frms, list)
qc_frm_free(qcc->conn->handle.qc, &frm);
}
/* Re-insert on-error QCS at the end of the send-list. */ /* Re-insert on-error QCS at the end of the send-list. */
if (!LIST_ISEMPTY(&qcs_failed)) { if (!LIST_ISEMPTY(&qcs_failed)) {
@ -2719,6 +2715,8 @@ static void qcc_release(struct qcc *qcc)
qc_frm_free(qcc->conn->handle.qc, &frm); qc_frm_free(qcc->conn->handle.qc, &frm);
} }
quic_pacing_reset(&qcc->tx.pacer);
if (qcc->app_ops && qcc->app_ops->release) if (qcc->app_ops && qcc->app_ops->release)
qcc->app_ops->release(qcc->ctx); qcc->app_ops->release(qcc->ctx);
TRACE_PROTO("application layer released", QMUX_EV_QCC_END, conn); TRACE_PROTO("application layer released", QMUX_EV_QCC_END, conn);