]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: do not account backend connections into maxconn
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 10 Nov 2025 14:24:35 +0000 (15:24 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 12 Nov 2025 13:45:00 +0000 (14:45 +0100)
Remove QUIC backend connections from global actconn accounting. Indeed,
this counter is only used on the frontend side. This is required to
ensure maxconn coherence.

src/quic_conn.c

index 90f3051f7d14f66c7529660e20f8ef5c867fb6e7..5ca9a3d1f1812d73085cf5fc14737c396dcfa852 100644 (file)
@@ -1101,13 +1101,6 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
 
        TRACE_ENTER(QUIC_EV_CONN_INIT);
 
-       next_actconn = increment_actconn();
-       if (!next_actconn) {
-               _HA_ATOMIC_INC(&maxconn_reached);
-               TRACE_STATE("maxconn reached", QUIC_EV_CONN_INIT);
-               goto err;
-       }
-
        next_sslconn = increment_sslconn();
        if (!next_sslconn) {
                TRACE_STATE("sslconn reached", QUIC_EV_CONN_INIT);
@@ -1115,6 +1108,13 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
        }
 
        if (l) {
+               next_actconn = increment_actconn();
+               if (!next_actconn) {
+                       _HA_ATOMIC_INC(&maxconn_reached);
+                       TRACE_STATE("maxconn reached", QUIC_EV_CONN_INIT);
+                       goto err;
+               }
+
                next_handshake = quic_increment_curr_handshake(l);
                if (!next_handshake) {
                        TRACE_STATE("max handshake reached", QUIC_EV_CONN_INIT);
@@ -1638,9 +1638,17 @@ int quic_conn_release(struct quic_conn *qc)
                HA_ATOMIC_DEC(&qc->prx_counters->half_open_conn);
        }
 
-       /* Connection released before handshake completion. */
-       if (unlikely(qc->state < QUIC_HS_ST_COMPLETE)) {
-               if (!qc_is_back(qc)) {
+       /* Decrement global counters when quic_conn is deallocated.
+        * quic_conn_closed instances are not accounted as they run for a short
+        * time with limited resources.
+        */
+       _HA_ATOMIC_DEC(&global.sslconns);
+
+       if (!qc_is_back(qc)) {
+               _HA_ATOMIC_DEC(&actconn);
+
+               /* Connection released before handshake completion. */
+               if (unlikely(qc->state < QUIC_HS_ST_COMPLETE)) {
                        BUG_ON(qc->li->rx.quic_curr_handshake == 0);
                        HA_ATOMIC_DEC(&qc->li->rx.quic_curr_handshake);
                }
@@ -1649,13 +1657,6 @@ int quic_conn_release(struct quic_conn *qc)
        pool_free(pool_head_quic_conn, qc);
        qc = NULL;
 
-       /* Decrement global counters when quic_conn is deallocated.
-        * quic_conn_closed instances are not accounted as they run for a short
-        * time with limited resources.
-        */
-       _HA_ATOMIC_DEC(&actconn);
-       _HA_ATOMIC_DEC(&global.sslconns);
-
        TRACE_PROTO("QUIC conn. freed", QUIC_EV_CONN_FREED, qc);
  leave:
        TRACE_LEAVE(QUIC_EV_CONN_CLOSE, qc);