]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: listener: enforce all_threads_mask on bind_thread on init
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Feb 2020 09:15:34 +0000 (10:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Feb 2020 09:21:49 +0000 (10:21 +0100)
When intializing a listener, let's make sure the bind_thread mask is
always limited to all_threads_mask when inserting the FD. This will
avoid seeing listening FDs with bits corresponding to threads that are
not active (e.g. when using "bind ... process 1/even"). The side effect
is very limited, all that was identified is that atomic operations are
used in fd_update_events() when not necessary. It's more a matter of
long-term correctness in practice.

This fix might be backported as far as 1.8 (then proto_sockpair must
be dropped).

src/proto_sockpair.c
src/proto_tcp.c
src/proto_uxst.c

index a6005ee5bf99a39283e0817bb7e3d0953e266d25..bdc7ebee0f8b5106db7055fea6674b81bd6b4b3e 100644 (file)
@@ -158,7 +158,7 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
        listener->state = LI_LISTEN;
 
        fd_insert(fd, listener, listener->proto->accept,
-                 thread_mask(listener->bind_conf->bind_thread));
+                 thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
 
        return err;
 
index df4e5a4d2d2d8f41125eb6702af4818bd8a2f897..197cb432b90b53040ea599d70c4615de3bd004bd 100644 (file)
@@ -999,7 +999,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
        listener->state = LI_LISTEN;
 
        fd_insert(fd, listener, listener->proto->accept,
-                 thread_mask(listener->bind_conf->bind_thread));
+                 thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
 
  tcp_return:
        if (msg && errlen) {
index 2a5e4319da81ce783539473652da35cd7db07831..61c89d54573cb3a5bcb913e1887d0f317d79eff4 100644 (file)
@@ -343,7 +343,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
        listener->state = LI_LISTEN;
 
        fd_insert(fd, listener, listener->proto->accept,
-                 thread_mask(listener->bind_conf->bind_thread));
+                 thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
 
        return err;