]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: listener: only enable a listening listener if needed
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2020 12:54:00 +0000 (13:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2020 13:22:42 +0000 (14:22 +0100)
The test on listener->state == LI_LISTEN is not sufficient to decide
if we need to enable a listener. Indeed, there is a very special case
which is the inherited FD shared, which has to reflect the real socket
state even after the previous test, and as such needs to remain in
LI_LISTEN state. In this case we don't want a worker to start the
master's listener nor conversely. Let's add a specific test for this.

src/listener.c

index 1947fdb5383345bc8735118ff9fcaa92f40e9dcb..7f038c4a3d7224fc864c24b4fd1a62975ec228f2 100644 (file)
@@ -257,7 +257,8 @@ void enable_listener(struct listener *listener)
        if (listener->state == LI_LISTEN) {
                BUG_ON(listener->rx.fd == -1);
                if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
-                   !(proc_mask(listener->rx.settings->bind_proc) & pid_bit)) {
+                   (!!master != !!(listener->rx.flags & RX_F_MWORKER) ||
+                    !(proc_mask(listener->rx.settings->bind_proc) & pid_bit))) {
                        /* we don't want to enable this listener and don't
                         * want any fd event to reach it.
                         */