]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: quic: release closing connections on stopping
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 8 Mar 2023 09:37:45 +0000 (10:37 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 8 Mar 2023 13:41:28 +0000 (14:41 +0100)
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.

include/haproxy/quic_conn.h
src/haproxy.c

index 8b7a43a5f35aee0f202161f9e94bffb5007aaac9..8342c9bafdd1390cacdb4afae93accf291fdff23 100644 (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 */
index eb490804a0bab97d3627517b3d7bc8179ec61f54..19463f29e1286908b38952cad3220b66ba473a96 100644 (file)
 #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;
                                }