From: Amaury Denoyelle Date: Wed, 8 Mar 2023 09:37:45 +0000 (+0100) Subject: MEDIUM: quic: release closing connections on stopping X-Git-Tag: v2.8-dev5~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5907fede87388581353ca1604510b909ddb6d95e;p=thirdparty%2Fhaproxy.git MEDIUM: quic: release closing connections on stopping Since the following commit : commit fb375574f947143e185225558c274ac00a3f8cb4 MINOR: quic: mark quic-conn as jobs on socket allocation quic-conn instances are marked as jobs. This prevent haproxy process to stop while there is transfer in progress. To not delay process termination, idle connections are woken up through their MUX instances to be able to release them immediately. However, there is no mechanism to wake up quic connections left on closing or draining state. This means that haproxy process termination is delayed until every closing quic connections timer has expired. To improve this, a new function quic_handle_stopping() is called when haproxy process is stopping. It simply wakes up the idle timer task of all connections in the global closing list. These connections will thus be released immediately to not interrupt haproxy process stopping. This should be backported up to 2.7. --- diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index 8b7a43a5f3..8342c9bafd 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -725,5 +725,19 @@ void qc_kill_conn(struct quic_conn *qc); int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *qc, struct listener *li); +/* Wake up every QUIC connections on closing/draining state if process stopping + * is active. They will be immediately released so this ensures haproxy process + * stopping is not delayed by them. + */ +static inline void quic_handle_stopping(void) +{ + struct quic_conn *qc; + + if (stopping) { + list_for_each_entry(qc, &th_ctx->quic_conns_clo, el_th_ctx) + task_wakeup(qc->idle_timer_task, TASK_WOKEN_OTHER); + } +} + #endif /* USE_QUIC */ #endif /* _HAPROXY_QUIC_CONN_H */ diff --git a/src/haproxy.c b/src/haproxy.c index eb490804a0..19463f29e1 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -115,7 +115,7 @@ #include #include #include -#include +#include #include #include #include @@ -2971,9 +2971,12 @@ void run_poll_loop() int i; if (stopping) { - /* stop muxes before acknowledging stopping */ + /* stop muxes/quic-conns before acknowledging stopping */ if (!(tg_ctx->stopping_threads & ti->ltid_bit)) { task_wakeup(mux_stopping_data[tid].task, TASK_WOKEN_OTHER); +#ifdef USE_QUIC + quic_handle_stopping(); +#endif wake = 1; }