From: Amaury Denoyelle Date: Mon, 31 Jan 2022 14:41:14 +0000 (+0100) Subject: MINOR: mux-quic: release idle conns on process stopping X-Git-Tag: v2.6-dev1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e0969d6cf40fa05a9dfe9f49b2b75a08f671af5;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: release idle conns on process stopping 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. --- diff --git a/src/mux_quic.c b/src/mux_quic.c index 7cd1231717..58d8c42c15 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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 =