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.
This commit is contained in:
Amaury Denoyelle 2023-03-08 10:37:45 +01:00
parent 2d37629222
commit 5907fede87
2 changed files with 19 additions and 2 deletions

View File

@ -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 */

View File

@ -115,7 +115,7 @@
#include <haproxy/namespace.h>
#include <haproxy/net_helper.h>
#include <haproxy/openssl-compat.h>
#include <haproxy/quic_conn-t.h>
#include <haproxy/quic_conn.h>
#include <haproxy/quic_tp-t.h>
#include <haproxy/pattern.h>
#include <haproxy/peers.h>
@ -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;
}