BUG/MINOR: listener: enforce all_threads_mask on bind_thread on init

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).

(cherry picked from commit 0948a781fce19a032b71e65239d6bc5d10c97522)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 507e044a18994fc8cc087ace12ab5feb553f9670)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index e7dd670..23c8f95 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -158,7 +158,7 @@
 	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;
 
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index cfd58e6..c6f70d2 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1082,7 +1082,7 @@
 	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) {
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 9dd4bb4..df813a1 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -343,7 +343,7 @@
 	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;