]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-quic: always notify stream upper layer on reset
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Nov 2026 14:03:04 +0000 (15:03 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 3 Dec 2026 13:57:45 +0000 (14:57 +0100)
Function qcc_reset_stream() is used when the stream is reset
prematurely. Along the RESET_STREAM emission, it also notifies the
stream upper layer, so that the error is transferred to the other MUX
side.

Previously, the function was skipped if the stream was already locally
closed, as RESET_STREAM is unnecessary in this case. However, this
causes an issue on the backend side as the call is skipped if the
request is already transferred. The error is thus not reported on the
other side and the client will be left waiting until the server timeout
is hit.

On the frontend side, impact is much more limited. If the stream is
locally closed, the server has already transmitted its response and is
no longer waiting. The only user-visible change is on haproxy stream
termination log, with a possible client abort (C---) now reported.

Fix this by adjusting qcc_reset_stream() so that, when the stream is
locally closed, upper-layer notification is still executed even though
the RESET_STREAM emission is skipped.

To ensure notification is only performed once, an additionnal check is
performed to skip it if SE_FL_ERROR or SE_FL_ERR_PENDING is already set.
As a side-effect, this prevents the termination event code from being
overwritten.

This must be backported up to 3.3 after a period of observation, as this
is mainly an issue on the backend side.

src/mux_quic.c

index 52e6c1a8e9dfaa7420f1c13f6c74d41742a8fa47..9ef88c277d9d5afe108e8cfcfa903194a24e32f6 100644 (file)
@@ -1808,17 +1808,27 @@ static void _qcc_send_stream(struct qcs *qcs, int urg)
        }
 }
 
-/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err>. If
- * <tevt> is non null, it is used as a stream level termination event code.
+/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err> and
+ * notify stream upper layer. If <tevt> is non null, it is used as the stream
+ * level termination event code.
  */
 void qcc_reset_stream(struct qcs *qcs, int err, int tevt)
 {
        struct qcc *qcc = qcs->qcc;
        const uint64_t diff = qcs_prep_bytes(qcs);
 
-       if ((qcs->flags & QC_SF_TO_RESET) || qcs_is_close_local(qcs))
+       /* early return if stream reset was already performed */
+       if (qcs->flags & QC_SF_TO_RESET)
                return;
 
+       /* RS is unneeded if stream is already locally closed. Upper layer
+        * still needs to be notified.
+        */
+       if (qcs_is_close_local(qcs)) {
+               TRACE_DEVEL("RS emission skipped", QMUX_EV_QCS_END, qcc->conn, qcs);
+               goto out;
+       }
+
        /* TODO if QCS waiting for buffer, it could be removed from
         * <qcc.buf_wait_list> if sending is closed now.
         */
@@ -1854,16 +1864,17 @@ void qcc_reset_stream(struct qcs *qcs, int err, int tevt)
                qcs->tx.fc.off_soft = qcs->tx.fc.off_real;
        }
 
+       _qcc_send_stream(qcs, 1);
+       tasklet_wakeup(qcc->wait_event.tasklet);
+
+ out:
        /* Report send error to stream-endpoint layer. */
-       if (qcs_sc(qcs)) {
+       if (qcs_sc(qcs) && !se_fl_test(qcs->sd, SE_FL_ERROR|SE_FL_ERR_PENDING)) {
                se_fl_set_error(qcs->sd);
                if (tevt)
                        se_report_term_evt(qcs->sd, tevt);
                qcs_alert(qcs);
        }
-
-       _qcc_send_stream(qcs, 1);
-       tasklet_wakeup(qcc->wait_event.tasklet);
 }
 
 /* Register <qcs> stream for STREAM emission. Set <urg> to 1 if stream content