]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: fix FD leak upon reload
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 26 Nov 2018 10:53:40 +0000 (11:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 18:31:17 +0000 (19:31 +0100)
We reintroduced some FDs leaking by using a poller and some listeners in
the master.

The master proxy needs to be stopped to avoid leaking its listeners, the
polling loop needs to be deinit, and the thread waker pipe need to be
closed too.

No backport needed.

src/haproxy.c

index b4e12f14a910b484ea37b21e77803e972beddbd6..2c42a7096a353250592c7412762e70a910366d00 100644 (file)
@@ -704,6 +704,7 @@ static void mworker_reload()
        int next_argc = 0;
        int j;
        char *msg = NULL;
+       struct per_thread_deinit_fct *ptdf;
 
        mworker_block_signals();
 #if defined(USE_SYSTEMD)
@@ -714,6 +715,18 @@ static void mworker_reload()
 
        mworker_proc_list_to_env(); /* put the children description in the env */
 
+       /* during the reload we must ensure that every FDs that can't be
+        * reuse (ie those that are not referenced in the proc_list)
+        * are closed or they will leak. */
+
+       /* close the listeners FD */
+       mworker_cli_proxy_stop();
+       /* close the poller FD and the thread waker pipe FD */
+       list_for_each_entry(ptdf, &per_thread_deinit_list, list)
+               ptdf->fct();
+       if (fdtab)
+               deinit_pollers();
+
        /* compute length  */
        while (next_argv[next_argc])
                next_argc++;