Skip to content

Commit e2a08ab

Browse files
committed
MINOR: quic_pacing: define frms list and use it for MUX STREAM emission
1 parent 2613193 commit e2a08ab

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

include/haproxy/quic_pacing-t.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#ifndef _HAPROXY_QUIC_PACING_T_H
22
#define _HAPROXY_QUIC_PACING_T_H
33

4+
#include <haproxy/api-t.h>
45
#include <haproxy/quic_cc-t.h>
56

67
struct quic_pacer {
8+
struct list frms;
79
const struct quic_cc_path *path;
810
};
911

include/haproxy/quic_pacing.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@
33

44
#include <haproxy/quic_pacing-t.h>
55

6+
#include <haproxy/list.h>
7+
#include <haproxy/quic_frame.h>
8+
69
static inline void quic_pacing_init(struct quic_pacer *pacer,
710
const struct quic_cc_path *path)
811
{
12+
LIST_INIT(&pacer->frms);
913
pacer->path = path;
1014
}
1115

16+
static inline void quic_pacing_reset(struct quic_pacer *pacer)
17+
{
18+
struct quic_frame *frm;
19+
20+
while (!LIST_ISEMPTY(&pacer->frms)) {
21+
frm = LIST_ELEM(pacer->frms.n, struct quic_frame *, list);
22+
/* qc_frm_free is responsible to detach frm from pacer list. */
23+
qc_frm_free(NULL, &frm);
24+
}
25+
}
26+
27+
static inline struct list *quic_pacing_frms(struct quic_pacer *pacer)
28+
{
29+
return &pacer->frms;
30+
}
31+
1232
#endif /* _HAPROXY_QUIC_PACING_H */

src/mux_quic.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <haproxy/quic_enc.h>
2020
#include <haproxy/quic_fctl.h>
2121
#include <haproxy/quic_frame.h>
22+
#include <haproxy/quic_pacing.h>
2223
#include <haproxy/quic_sock.h>
2324
#include <haproxy/quic_stream.h>
2425
#include <haproxy/quic_tp-t.h>
@@ -2244,8 +2245,8 @@ static int qcs_send(struct qcs *qcs, struct list *frms, uint64_t window_conn)
22442245
*/
22452246
static int qcc_io_send(struct qcc *qcc)
22462247
{
2247-
struct list frms = LIST_HEAD_INIT(frms);
22482248
/* Temporary list for QCS on error. */
2249+
struct list *frms = quic_pacing_frms(&qcc->tx.pacer);
22492250
struct list qcs_failed = LIST_HEAD_INIT(qcs_failed);
22502251
struct qcs *qcs, *qcs_tmp, *first_qcs = NULL;
22512252
uint64_t window_conn = qfctl_rcap(&qcc->tx.fc);
@@ -2338,7 +2339,7 @@ static int qcc_io_send(struct qcc *qcc)
23382339

23392340
if (!qfctl_rblocked(&qcc->tx.fc) &&
23402341
!qfctl_rblocked(&qcs->tx.fc) && window_conn > total) {
2341-
if ((ret = qcs_send(qcs, &frms, window_conn - total)) < 0) {
2342+
if ((ret = qcs_send(qcs, frms, window_conn - total)) < 0) {
23422343
/* Temporarily remove QCS from send-list. */
23432344
LIST_DEL_INIT(&qcs->el_send);
23442345
LIST_APPEND(&qcs_failed, &qcs->el_send);
@@ -2362,7 +2363,7 @@ static int qcc_io_send(struct qcc *qcc)
23622363
/* Retry sending until no frame to send, data rejected or connection
23632364
* flow-control limit reached.
23642365
*/
2365-
while (qcc_send_frames(qcc, &frms) == 0 && !qfctl_rblocked(&qcc->tx.fc)) {
2366+
while ((ret = qcc_send_frames(qcc, frms)) == 0 && !qfctl_rblocked(&qcc->tx.fc)) {
23662367
window_conn = qfctl_rcap(&qcc->tx.fc);
23672368
resent = 0;
23682369

@@ -2380,7 +2381,7 @@ static int qcc_io_send(struct qcc *qcc)
23802381
BUG_ON(resent > window_conn);
23812382

23822383
if (!qfctl_rblocked(&qcs->tx.fc) && window_conn > resent) {
2383-
if ((ret = qcs_send(qcs, &frms, window_conn - resent)) < 0) {
2384+
if ((ret = qcs_send(qcs, frms, window_conn - resent)) < 0) {
23842385
LIST_DEL_INIT(&qcs->el_send);
23852386
LIST_APPEND(&qcs_failed, &qcs->el_send);
23862387
continue;
@@ -2394,12 +2395,7 @@ static int qcc_io_send(struct qcc *qcc)
23942395

23952396
sent_done:
23962397
/* Deallocate frames that the transport layer has rejected. */
2397-
if (!LIST_ISEMPTY(&frms)) {
2398-
struct quic_frame *frm, *frm2;
2399-
2400-
list_for_each_entry_safe(frm, frm2, &frms, list)
2401-
qc_frm_free(qcc->conn->handle.qc, &frm);
2402-
}
2398+
quic_pacing_reset(&qcc->tx.pacer);
24032399

24042400
/* Re-insert on-error QCS at the end of the send-list. */
24052401
if (!LIST_ISEMPTY(&qcs_failed)) {
@@ -2719,6 +2715,8 @@ static void qcc_release(struct qcc *qcc)
27192715
qc_frm_free(qcc->conn->handle.qc, &frm);
27202716
}
27212717

2718+
quic_pacing_reset(&qcc->tx.pacer);
2719+
27222720
if (qcc->app_ops && qcc->app_ops->release)
27232721
qcc->app_ops->release(qcc->ctx);
27242722
TRACE_PROTO("application layer released", QMUX_EV_QCC_END, conn);

0 commit comments

Comments
 (0)