]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd/thread: get rid of thread_mask()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Jul 2022 09:22:42 +0000 (11:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:43:10 +0000 (19:43 +0200)
Since commit d2494e048 ("BUG/MEDIUM: peers/config: properly set the
thread mask") there must not remain any single case of a receiver that
is bound nowhere, so there's no need anymore for thread_mask().

We're adding a test in fd_insert() to make sure this doesn't happen by
accident though, but the function was removed and its rare uses were
replaced with the original value of the bind_thread msak.

include/haproxy/fd.h
include/haproxy/thread.h
src/listener.c
src/proto_sockpair.c
src/sock_inet.c
src/sock_unix.c

index 7d67cef4312074cbd4027b8cc689bc3e39a4d36d..2b2c3ff38372c577a223eca1d6913a4137417f05 100644 (file)
@@ -334,6 +334,7 @@ static inline void fd_insert(int fd, void *owner, void (*iocb)(int fd), unsigned
        BUG_ON(fd < 0 || fd >= global.maxsock);
        BUG_ON(fdtab[fd].owner != NULL);
        BUG_ON(fdtab[fd].state != 0);
+       BUG_ON(thread_mask == 0);
 
        fdtab[fd].owner = owner;
        fdtab[fd].iocb = iocb;
index fe2312756693f32e5d3feca9f7cb3b4163fd8d1a..67aefc7a3c959fc42a60e91ce5479bb94079986d 100644 (file)
@@ -469,10 +469,4 @@ void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l,
 
 #endif /* USE_THREAD */
 
-/* returns a mask if set, otherwise all_threads_mask */
-static inline unsigned long thread_mask(unsigned long mask)
-{
-       return mask ? mask : all_threads_mask;
-}
-
 #endif /* _HAPROXY_THREAD_H */
index 6b088026f8b5e3ad260bf9c81ddad7a8fbe7d590..5b91faf3eac90359cd22dfd5e36a41aa80a0f077 100644 (file)
@@ -992,7 +992,7 @@ void listener_accept(struct listener *l)
                if (l->rx.flags & RX_F_LOCAL_ACCEPT)
                        goto local_accept;
 
-               mask = thread_mask(l->rx.bind_thread) & all_threads_mask;
+               mask = l->rx.bind_thread & all_threads_mask;
                if (atleast2(mask) && (global.tune.options & GTUNE_LISTENER_MQ) && !stopping) {
                        struct accept_queue_ring *ring;
                        unsigned int t, t0, t1, t2;
index 54cc34f236ce425b1be288dcb4fc711caf0fe7b7..234ec108a7e53032397d60bd861e316d286d3c57 100644 (file)
@@ -157,7 +157,7 @@ int sockpair_bind_receiver(struct receiver *rx, char **errmsg)
 
        rx->flags |= RX_F_BOUND;
 
-       fd_insert(rx->fd, rx->owner, rx->iocb, thread_mask(rx->bind_thread) & all_threads_mask);
+       fd_insert(rx->fd, rx->owner, rx->iocb, rx->bind_thread & all_threads_mask);
        return err;
 
  bind_return:
index 46cc16a1c3ebd10f78931bec5ed63a05c567f18a..bc3b762f7aa2cc7d5805156a9f6634b2ec7384d1 100644 (file)
@@ -390,7 +390,7 @@ int sock_inet_bind_receiver(struct receiver *rx, char **errmsg)
        rx->fd = fd;
        rx->flags |= RX_F_BOUND;
 
-       fd_insert(fd, rx->owner, rx->iocb, thread_mask(rx->bind_thread) & all_threads_mask);
+       fd_insert(fd, rx->owner, rx->iocb, rx->bind_thread & all_threads_mask);
 
        /* for now, all regularly bound TCP listeners are exportable */
        if (!(rx->flags & RX_F_INHERITED))
index 143295e79af4025c4795d2a9250bd0ce11843642..6544ccf0912cf428bc29b174906d2b6e4d354adf 100644 (file)
@@ -284,7 +284,7 @@ int sock_unix_bind_receiver(struct receiver *rx, char **errmsg)
        rx->fd = fd;
        rx->flags |= RX_F_BOUND;
 
-       fd_insert(fd, rx->owner, rx->iocb, thread_mask(rx->bind_thread) & all_threads_mask);
+       fd_insert(fd, rx->owner, rx->iocb, rx->bind_thread & all_threads_mask);
 
        /* for now, all regularly bound TCP listeners are exportable */
        if (!(rx->flags & RX_F_INHERITED))