]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: extend qc_send_mux() return type with a dedicated enum
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Oct 2024 14:31:26 +0000 (16:31 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 Nov 2024 15:16:48 +0000 (16:16 +0100)
This commit is part of a adjustment on QUIC transport send API to
support pacing. Here, qc_send_mux() return type has been changed to use
a new enum quic_tx_err.

This is useful to explain different failure causes of emission. For now,
only two values have been defined : NONE and FATAL. When pacing will be
implemented, a new value would be added to specify that emission was
interrupted on pacing. This won't be a fatal error as this allows to
retry emission but not immediately.

include/haproxy/quic_tx-t.h
include/haproxy/quic_tx.h
src/mux_quic.c
src/quic_tx.c

index efbdfe68703ba1ffc7fb644dc0365357f98dee24..359869a314270e81c680513ca73ec33ead2541ba 100644 (file)
@@ -64,4 +64,9 @@ enum qc_build_pkt_err {
        QC_BUILD_PKT_ERR_BUFROOM,  /* no more room in input buf or congestion window */
 };
 
+enum quic_tx_err {
+       QUIC_TX_ERR_NONE,
+       QUIC_TX_ERR_FATAL,
+};
+
 #endif /* _HAPROXY_TX_T_H */
index b77d6a20a5172ceff360a846ebf1efaf2e12a5b0..21f7eecf3a302b14ace27101c4d2adcfb7fc175a 100644 (file)
@@ -33,7 +33,7 @@ void qc_txb_release(struct quic_conn *qc);
 int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf);
 struct buffer *qc_get_txb(struct quic_conn *qc);
 
-int qc_send_mux(struct quic_conn *qc, struct list *frms);
+enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms);
 
 void qel_register_send(struct list *send_list, struct quic_enc_level *qel,
                        struct list *frms);
index 80f4eff2d0643b0ff750426f5c08af95819eee1d..ffd53b9c543a1874909f52a15720f8e44a3d2b80 100644 (file)
@@ -2074,6 +2074,8 @@ static int qcc_subscribe_send(struct qcc *qcc)
  */
 static int qcc_send_frames(struct qcc *qcc, struct list *frms)
 {
+       enum quic_tx_err ret;
+
        TRACE_ENTER(QMUX_EV_QCC_SEND, qcc->conn);
 
        if (LIST_ISEMPTY(frms)) {
@@ -2081,7 +2083,8 @@ static int qcc_send_frames(struct qcc *qcc, struct list *frms)
                return 1;
        }
 
-       if (!qc_send_mux(qcc->conn->handle.qc, frms)) {
+       ret = qc_send_mux(qcc->conn->handle.qc, frms);
+       if (ret == QUIC_TX_ERR_FATAL) {
                TRACE_DEVEL("error on sending", QMUX_EV_QCC_SEND, qcc->conn);
                qcc_subscribe_send(qcc);
                goto err;
index 6431b3dfa83b16b5edb702c4d9659fda6fcae536..a99b2c4b490804719b7faa17faf6dc4d6bc3a677 100644 (file)
@@ -469,10 +469,11 @@ int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf)
  *
  * Returns the result from qc_send() function.
  */
-int qc_send_mux(struct quic_conn *qc, struct list *frms)
+enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms)
 {
        struct list send_list = LIST_HEAD_INIT(send_list);
-       int ret;
+       enum quic_tx_err ret = QUIC_TX_ERR_NONE;
+       int sent;
 
        TRACE_ENTER(QUIC_EV_CONN_TXPKT, qc);
        BUG_ON(qc->mux_state != QC_MUX_READY); /* Only MUX can uses this function so it must be ready. */
@@ -480,7 +481,7 @@ int qc_send_mux(struct quic_conn *qc, struct list *frms)
        if (qc->conn->flags & CO_FL_SOCK_WR_SH) {
                qc->conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH;
                TRACE_DEVEL("connection on error", QUIC_EV_CONN_TXPKT, qc);
-               return 0;
+               return QUIC_TX_ERR_FATAL;
        }
 
        /* Try to send post handshake frames first unless on 0-RTT. */
@@ -493,7 +494,9 @@ int qc_send_mux(struct quic_conn *qc, struct list *frms)
 
        TRACE_STATE("preparing data (from MUX)", QUIC_EV_CONN_TXPKT, qc);
        qel_register_send(&send_list, qc->ael, frms);
-       ret = qc_send(qc, 0, &send_list, 0);
+       sent = qc_send(qc, 0, &send_list, 0);
+       if (sent <= 0)
+               ret = QUIC_TX_ERR_FATAL;
 
        TRACE_LEAVE(QUIC_EV_CONN_TXPKT, qc);
        return ret;