]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: release idle conns on process stopping
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 31 Jan 2022 14:41:14 +0000 (15:41 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Feb 2022 14:42:32 +0000 (15:42 +0100)
Implement the idle frontend connection cleanup for QUIC mux. Each
connection is registered on the mux_stopping_list. On process closing,
the mux is notified via a new function qc_wake. This function immediatly
release the connection if the parent proxy is stopped.

This allows to quickly close the process even if there is QUIC
connection stucked on timeout.

src/mux_quic.c

index 7cd1231717a352d817b83b30045b3acca01c3f65..58d8c42c15a93b8091657a88f5a5065f32d34578 100644 (file)
@@ -247,6 +247,8 @@ static void qc_release(struct qcc *qcc)
        }
 
        if (conn) {
+               LIST_DEL_INIT(&conn->stopping_list);
+
                conn->qc->conn = NULL;
                conn->mux = NULL;
                conn->ctx = NULL;
@@ -498,6 +500,13 @@ static int qc_init(struct connection *conn, struct proxy *prx,
        qcc->task->context = qcc;
        qcc->task->expire = tick_add(now_ms, qcc->timeout);
 
+       if (!conn_is_back(conn)) {
+               if (!LIST_INLIST(&conn->stopping_list)) {
+                       LIST_APPEND(&mux_stopping_data[tid].list,
+                                   &conn->stopping_list);
+               }
+       }
+
        HA_ATOMIC_STORE(&conn->qc->qcc, qcc);
        /* init read cycle */
        tasklet_wakeup(qcc->wait_event.tasklet);
@@ -588,6 +597,20 @@ static int qc_unsubscribe(struct conn_stream *cs, int event_type, struct wait_ev
        return 0;
 }
 
+static int qc_wake(struct connection *conn)
+{
+       struct qcc *qcc = conn->ctx;
+
+       /* Check if a soft-stop is in progress.
+        * Release idling front connection if this is the case.
+        */
+       if (unlikely(conn->qc->li->bind_conf->frontend->flags & (PR_FL_DISABLED|PR_FL_STOPPED))) {
+               qc_release(qcc);
+       }
+
+       return 1;
+}
+
 static const struct mux_ops qc_ops = {
        .init = qc_init,
        .detach = qc_detach,
@@ -595,6 +618,7 @@ static const struct mux_ops qc_ops = {
        .snd_buf = qc_snd_buf,
        .subscribe = qc_subscribe,
        .unsubscribe = qc_unsubscribe,
+       .wake = qc_wake,
 };
 
 static struct mux_proto_list mux_proto_quic =