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 8b7a43a..8342c9b 100644
--- a/include/haproxy/quic_conn.h
+++ b/include/haproxy/quic_conn.h
@@ -725,5 +725,19 @@
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 eb49080..19463f2 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -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 @@
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;
}