]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: qmux: prevent pacing BUG_ON() on send syscall zero return
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 17 Nov 2026 15:15:48 +0000 (16:15 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Nov 2026 13:54:31 +0000 (14:54 +0100)
Previously, qcc_qmux_send_frames() would return 1 in case a send failed
on a transient error while nothing was emitted. However, this may
trigger a BUG_ON() in qcc_io_send() as this return value is reserved for
QUIC pacing support, not relevant with QMux.

Fix this by converting the return value to a negative value, which is
already used for fatal errors.

The caller is responsible for re-emitting the new the frame later. As
such, the prepared record is cleared from the send buffer to avoid a
duplicate emission on initial flush.

Note that this patch does not implement full support for QMux partial
emission if the send syscall accepts some but not all bytes, resulting
in a partially delivered frame. This must be implemented in a future
patch. Once this is the case, all code related to the handling of send
zero return can probably be removed.

This must be backported up to 3.4.

src/qcm_qmux.c

index 2a8cdb9e0e7eceaaa98e755b09e11f53fac366ab..5a4e243cf741918aac8371a86da33055e1d6293e 100644 (file)
@@ -292,8 +292,9 @@ static void qmux_ctrl_send(struct qcs *qcs, uint64_t data)
 
 /* Sends <frms> list of frames for <qcc> connection.
  *
- * Returns 0 if all data are emitted or a positive value if sending should be
- * retried later. A negative error code is used for a fatal failure.
+ * Returns 0 if all data are emitted. A negative error code is used for a fatal
+ * error with CO_FL_ERROR set or a transient error, in which case caller should
+ * retry later to emit remaining <frms> content.
  */
 int qcc_qmux_send_frames(struct qcc *qcc, struct list *frms)
 {
@@ -378,6 +379,10 @@ int qcc_qmux_send_frames(struct qcc *qcc, struct list *frms)
                        TRACE_DEVEL("snd_buf interrupted", QMUX_EV_QCC_SEND, qcc->conn);
                        if (split_frm)
                                LIST_INSERT(frms, &split_frm->list);
+                       /* Remove unsent record from buffer to avoid emitting
+                        * duplicate content during initial flush on next send.
+                        */
+                       b_sub(buf, lensz + (pos - old));
                        break;
                }
 
@@ -404,7 +409,7 @@ int qcc_qmux_send_frames(struct qcc *qcc, struct list *frms)
        else if (!LIST_ISEMPTY(frms)) {
                if (!(qcc->wait_event.events & SUB_RETRY_SEND))
                        conn->xprt->subscribe(conn, conn->xprt_ctx, SUB_RETRY_SEND, &qcc->wait_event);
-               ret = 1;
+               ret = -1;
        }
        else {
                ret = 0;