]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: mux_quic: do not perform unnecessary timeout handling on BE side
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 Apr 2026 15:58:27 +0000 (17:58 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 6 May 2026 06:57:35 +0000 (08:57 +0200)
MUX implements a timeout for HTTP keep-alive which monitors the delay
between two HTTP requests. This is only applicable for frontend
connections, as on the backend side idle connections can be kept in the
server pool. In QUIC mux, this timeout relies on QCC <idle_start> which
is refresh when the last request is terminated.

This patch modifies the refresh operation so that it is only performed
for frontend connections. This is not strictly necessary but the timeout
timeout management is now clearer and it eliminates an unnecessary
operation for backend connections.

Similarly, http-request timeout is also only applicable for frontend
connections. This relies on qcs_wait_http_req() function. A request QCS
is inserted in <opening_list> until the headers are received. This is
unnecessary on the backend side so this is excluded as well.

include/haproxy/mux_quic.h
src/mux_quic.c

index 6ba947785645a92593e8c42c041d7f40d5b10b1f..232dfe7d2103dde6c0302354e1a1d89e5b9f1f2b 100644 (file)
@@ -109,14 +109,16 @@ static inline void qcs_wait_http_req(struct qcs *qcs)
 {
        struct qcc *qcc = qcs->qcc;
 
-       /* A stream cannot be registered several times. */
-       BUG_ON_HOT(tick_isset(qcs->start));
-       qcs->start = now_ms;
-
-       /* qcc.opening_list size is limited by flow-control so no custom
-        * restriction is needed here.
-        */
-       LIST_APPEND(&qcc->opening_list, &qcs->el_opening);
+       if (!conn_is_back(qcc->conn)) {
+               /* A stream cannot be registered several times. */
+               BUG_ON_HOT(tick_isset(qcs->start));
+               qcs->start = now_ms;
+
+               /* qcc.opening_list size is limited by flow-control so no
+                * custom restriction is needed here.
+                */
+               LIST_APPEND(&qcc->opening_list, &qcs->el_opening);
+       }
 }
 
 void qcc_show_quic(struct qcc *qcc);
index 5300ca5f633a3b9b61321afd26873b2534b1b15f..ac798e475ea634c07ff749f34a64ebfa493d33cd 100644 (file)
@@ -259,6 +259,12 @@ static forceinline void qcc_reset_idle_start(struct qcc *qcc)
        qcc->idle_start = now_ms;
 }
 
+/* Return true if the mux timeout should be armed. */
+static inline int qcc_may_expire(struct qcc *qcc)
+{
+       return !qcc->nb_sc;
+}
+
 /* Decrement <qcc> sc. */
 static forceinline void qcc_rm_sc(struct qcc *qcc)
 {
@@ -268,7 +274,7 @@ static forceinline void qcc_rm_sc(struct qcc *qcc)
        /* Reset qcc idle start for http-keep-alive timeout. Timeout will be
         * refreshed after this on stream detach.
         */
-       if (!qcc->nb_sc && !qcc->nb_hreq)
+       if (!conn_is_back(qcc->conn) && qcc_may_expire(qcc) && !qcc->nb_hreq)
                qcc_reset_idle_start(qcc);
 }
 
@@ -281,7 +287,7 @@ static forceinline void qcc_rm_hreq(struct qcc *qcc)
        /* Reset qcc idle start for http-keep-alive timeout. Timeout will be
         * refreshed after this on I/O handler.
         */
-       if (!qcc->nb_sc && !qcc->nb_hreq)
+       if (!conn_is_back(qcc->conn) && qcc_may_expire(qcc) && !qcc->nb_hreq)
                qcc_reset_idle_start(qcc);
 }
 
@@ -308,12 +314,6 @@ static inline int qcc_is_dead(const struct qcc *qcc)
        return 0;
 }
 
-/* Return true if the mux timeout should be armed. */
-static inline int qcc_may_expire(struct qcc *qcc)
-{
-       return !qcc->nb_sc;
-}
-
 /* Refresh the timeout on <qcc> if needed depending on its state. */
 static void qcc_refresh_timeout(struct qcc *qcc)
 {