]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic_pacing: define frms list and use it for MUX STREAM emission
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Oct 2024 14:26:12 +0000 (16:26 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 31 Oct 2024 09:32:50 +0000 (10:32 +0100)
include/haproxy/quic_pacing-t.h
include/haproxy/quic_pacing.h
src/mux_quic.c

index fd307457154b68c5aab7ef9ac0f0996f82f5cc4f..220066994b1bcd935ae2e9e23e90deed0cad381b 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef _HAPROXY_QUIC_PACING_T_H
 #define _HAPROXY_QUIC_PACING_T_H
 
+#include <haproxy/api-t.h>
 #include <haproxy/quic_cc-t.h>
 
 struct quic_pacer {
+       struct list frms;
        const struct quic_cc_path *path;
 };
 
index eff7315988319ae7757d9c8e607869c39ae60561..f58c3a34029c60053c1511164bb12c71111676dc 100644 (file)
@@ -3,10 +3,30 @@
 
 #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,
                                     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 */
index 7b3f705e76e54cc2fb3eedfb24a24bbf33ddec44..05cfa31635ec45afd19d217325fef0fecd3aa12a 100644 (file)
@@ -19,6 +19,7 @@
 #include <haproxy/quic_enc.h>
 #include <haproxy/quic_fctl.h>
 #include <haproxy/quic_frame.h>
+#include <haproxy/quic_pacing.h>
 #include <haproxy/quic_sock.h>
 #include <haproxy/quic_stream.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)
 {
-       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);