]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: threads: don't close the thread waker pipe if not init
authorWilliam Lallemand <wlallemand@haproxy.com>
Sat, 15 Dec 2018 21:34:31 +0000 (22:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 15 Dec 2018 22:33:32 +0000 (23:33 +0100)
This bugfix concerns the thread deinit but affects the master process.

When the master process falls in wait mode (it fails to reload the
configuration), it launches the deinit_pollers_per_thread and close the
thread waker pipe. It closes rd (-1) and wr (0).

Closing a FD in the master can have several sides effects and the
process will probably quit at some point.

In this case it assigns 0 to the socketpair of a worker during the next
correct reload, and then closes the socketpair once it falls in wait
mode again. The worker assumes that the master died and leaves.

src/fd.c

index a787a0957b9df5004fda550cb7778f2322e90598..84cb9080c27174447d16f88a59d5f2fb046d423c 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -503,8 +503,15 @@ static void deinit_pollers_per_thread()
 {
        free(fd_updt);
        fd_updt = NULL;
-       close(poller_rd_pipe);
-       close(poller_wr_pipe[tid]);
+
+       /* rd and wr are init at the same place, but only rd is init to -1, so
+         we rely to rd to close.   */
+       if (poller_rd_pipe > -1) {
+               close(poller_rd_pipe);
+               poller_rd_pipe = -1;
+               close(poller_wr_pipe[tid]);
+               poller_wr_pipe[tid] = -1;
+       }
 }
 
 /*