]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: centralize send operations in qc_send
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 4 Apr 2022 14:36:34 +0000 (16:36 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 7 Apr 2022 08:23:10 +0000 (10:23 +0200)
Regroup all features related to sending in qc_send(). This will be
useful when qc_send() will be called outside of the io-cb.

Currently, flow-control frames generation is now automatically
integrated in qc_send().

src/mux_quic.c

index 34e9291ae803d3e89e012b35f2d6d47a699a4170..34c0236cd5733c6744bebc958622d15a0479d235 100644 (file)
@@ -748,6 +748,36 @@ static int qc_send_frames(struct qcc *qcc, struct list *frms)
        return 0;
 }
 
+/* Send a MAX_STREAM_BIDI frame to update the limit of bidirectional streams
+ * allowed to be opened by the peer. The caller should have first checked if
+ * this is required with qc_is_max_streams_needed.
+ *
+ * Returns 0 on success else non-zero.
+ */
+static int qc_send_max_streams(struct qcc *qcc)
+{
+       struct list frms = LIST_HEAD_INIT(frms);
+       struct quic_frame *frm;
+
+       frm = pool_zalloc(pool_head_quic_frame);
+       BUG_ON(!frm); /* TODO handle this properly */
+
+       frm->type = QUIC_FT_MAX_STREAMS_BIDI;
+       frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi +
+                                           qcc->lfctl.cl_bidi_r;
+       TRACE_DEVEL("sending MAX_STREAMS frame", QMUX_EV_SEND_FRM, qcc->conn, NULL, frm);
+       LIST_APPEND(&frms, &frm->list);
+
+       if (qc_send_frames(qcc, &frms))
+               return 1;
+
+       /* save the new limit if the frame has been send. */
+       qcc->lfctl.ms_bidi += qcc->lfctl.cl_bidi_r;
+       qcc->lfctl.cl_bidi_r = 0;
+
+       return 0;
+}
+
 /* Proceed to sending. Loop through all available streams for the <qcc>
  * instance and try to send as much as possible.
  *
@@ -761,6 +791,9 @@ static int qc_send(struct qcc *qcc)
 
        TRACE_ENTER(QMUX_EV_QCC_SEND);
 
+       if (qc_is_max_streams_needed(qcc))
+               qc_send_max_streams(qcc);
+
        if (qcc->flags & QC_CF_BLK_MFCTL)
                return 0;
 
@@ -854,45 +887,12 @@ static int qc_release_detached_streams(struct qcc *qcc)
        return release;
 }
 
-/* Send a MAX_STREAM_BIDI frame to update the limit of bidirectional streams
- * allowed to be opened by the peer. The caller should have first checked if
- * this is required with qc_is_max_streams_needed.
- *
- * Returns 0 on success else non-zero.
- */
-static int qc_send_max_streams(struct qcc *qcc)
-{
-       struct list frms = LIST_HEAD_INIT(frms);
-       struct quic_frame *frm;
-
-       frm = pool_zalloc(pool_head_quic_frame);
-       BUG_ON(!frm); /* TODO handle this properly */
-
-       frm->type = QUIC_FT_MAX_STREAMS_BIDI;
-       frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi +
-                                           qcc->lfctl.cl_bidi_r;
-       TRACE_DEVEL("sending MAX_STREAMS frame", QMUX_EV_SEND_FRM, qcc->conn, NULL, frm);
-       LIST_APPEND(&frms, &frm->list);
-
-       if (qc_send_frames(qcc, &frms))
-               return 1;
-
-       /* save the new limit if the frame has been send. */
-       qcc->lfctl.ms_bidi += qcc->lfctl.cl_bidi_r;
-       qcc->lfctl.cl_bidi_r = 0;
-
-       return 0;
-}
-
 static struct task *qc_io_cb(struct task *t, void *ctx, unsigned int status)
 {
        struct qcc *qcc = ctx;
 
        TRACE_ENTER(QMUX_EV_QCC_WAKE);
 
-       if (qc_is_max_streams_needed(qcc))
-               qc_send_max_streams(qcc);
-
        qc_send(qcc);
 
        if (qc_release_detached_streams(qcc)) {