]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: add comments for send functions
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 22 Mar 2022 14:10:29 +0000 (15:10 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 23 Mar 2022 09:05:29 +0000 (10:05 +0100)
Add comments on qc_send and qcs_push_frame. Also adjust the return of
qc_send to reflect the total bytes sent. This has no impact as currently
the return value is not checked by the caller.

src/mux_quic.c

index fa0207ea567ae5d11189b705714ca06c4db085b3..e5dddeeae264bc2dbdcd85a90e8eef6e3817cd67 100644 (file)
@@ -351,6 +351,13 @@ static void qc_release(struct qcc *qcc)
        }
 }
 
+/* Prepare a STREAM frame for <qcs> instance. First, transfer data from
+ * <payload> to <out> buffer. The STREAM frame payload points to the <out>
+ * buffer. The frame is then pushed to <frm_list>. If <fin> is set, and the
+ * <payload> buf is emptied after transfer, FIN bit is set on the STREAM frame.
+ *
+ * Returns the total bytes of newly transferred data or a negative error code.
+ */
 static int qcs_push_frame(struct qcs *qcs, struct buffer *out,
                           struct buffer *payload, int fin,
                           struct list *frm_list)
@@ -513,11 +520,16 @@ static int qc_send_frames(struct qcc *qcc, struct list *frms)
        return 0;
 }
 
+/* Proceed to sending. Loop through all available streams for the <qcc>
+ * instance and try to send as much as possible.
+ *
+ * Returns the total of bytes sent to the transport layer.
+ */
 static int qc_send(struct qcc *qcc)
 {
        struct list frms = LIST_HEAD_INIT(frms);
        struct eb64_node *node;
-       int ret = 0;
+       int total = 0;
 
        fprintf(stderr, "%s\n", __func__);
 
@@ -541,7 +553,9 @@ static int qc_send(struct qcc *qcc)
                }
 
                if (b_data(buf) || b_data(out)) {
+                       int ret;
                        char fin = qcs->flags & QC_SF_FIN_STREAM;
+
                        ret = qcs_push_frame(qcs, out, buf, fin, &frms);
                        BUG_ON(ret < 0); /* TODO handle this properly */
 
@@ -553,6 +567,7 @@ static int qc_send(struct qcc *qcc)
 
                        fprintf(stderr, "%s ret=%d\n", __func__, ret);
                        qcs->tx.offset += ret;
+                       total += ret;
 
                        /* Subscribe if not all data can be send. */
                        if (b_data(buf)) {
@@ -564,9 +579,8 @@ static int qc_send(struct qcc *qcc)
        }
 
        qc_send_frames(qcc, &frms);
-       /* TODO adjust ret if not all frames are sent. */
 
-       return ret;
+       return total;
 }
 
 /* Release all streams that are already marked as detached. This is only done