]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: refactor timeout code
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 8 Jul 2025 08:44:44 +0000 (10:44 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 23 Jul 2025 12:36:48 +0000 (14:36 +0200)
This commit is a small reorganization of condition used into
qcc_refresh_timeout(). Its objective is to render the code more logical
before the next patch which will ensure that timeout is properly set for
backend connections.

src/mux_quic.c

index 97e006184a2234e1ea82db8840f9e8df6e693461..e7ca77a89dc6b5703e292c1d20845736e275a059 100644 (file)
@@ -316,8 +316,8 @@ static void qcc_refresh_timeout(struct qcc *qcc)
        }
 
        /* Frontend timeout management
-        * - shutdown done -> timeout client-fin
         * - detached streams with data left to send -> default timeout
+        * - shutdown done -> timeout client-fin
         * - stream waiting on incomplete request or no stream yet activated -> timeout http-request
         * - idle after stream processing -> timeout http-keep-alive
         *
@@ -329,8 +329,12 @@ static void qcc_refresh_timeout(struct qcc *qcc)
                        TRACE_DEVEL("pending output data", QMUX_EV_QCC_WAKE, qcc->conn);
                        qcc->task->expire = tick_add_ifset(now_ms, qcc->timeout);
                }
-               else if ((!LIST_ISEMPTY(&qcc->opening_list) || unlikely(!qcc->largest_bidi_r)) &&
-                        qcc->app_st < QCC_APP_ST_SHUT) {
+               else if (qcc->app_st >= QCC_APP_ST_SHUT) {
+                       TRACE_DEVEL("connection in closing", QMUX_EV_QCC_WAKE, qcc->conn);
+                       qcc->task->expire = tick_add_ifset(now_ms,
+                                                          qcc->shut_timeout);
+               }
+               else if (!LIST_ISEMPTY(&qcc->opening_list) || unlikely(!qcc->largest_bidi_r)) {
                        int timeout = px->timeout.httpreq;
                        struct qcs *qcs = NULL;
                        int base_time;
@@ -346,18 +350,11 @@ static void qcc_refresh_timeout(struct qcc *qcc)
                        qcc->task->expire = tick_add_ifset(base_time, timeout);
                }
                else {
-                       if (qcc->app_st >= QCC_APP_ST_SHUT) {
-                               TRACE_DEVEL("connection in closing", QMUX_EV_QCC_WAKE, qcc->conn);
-                               qcc->task->expire = tick_add_ifset(now_ms,
-                                                                  qcc->shut_timeout);
-                       }
-                       else {
-                               /* Use http-request timeout if keep-alive timeout not set */
-                               int timeout = tick_isset(px->timeout.httpka) ?
-                                             px->timeout.httpka : px->timeout.httpreq;
-                               TRACE_DEVEL("at least one request achieved but none currently in progress", QMUX_EV_QCC_WAKE, qcc->conn);
-                               qcc->task->expire = tick_add_ifset(qcc->idle_start, timeout);
-                       }
+                       /* Use http-request timeout if keep-alive timeout not set */
+                       int timeout = tick_isset(px->timeout.httpka) ?
+                                     px->timeout.httpka : px->timeout.httpreq;
+                       TRACE_DEVEL("at least one request achieved but none currently in progress", QMUX_EV_QCC_WAKE, qcc->conn);
+                       qcc->task->expire = tick_add_ifset(qcc->idle_start, timeout);
                }
        }