MINOR: fd/thread: get rid of thread_mask()

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.
This commit is contained in:
Willy Tarreau 2022-07-06 11:22:42 +02:00
parent 6bdf9452c0
commit 82e378aa8a
6 changed files with 5 additions and 10 deletions

View 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;

View 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 */

View 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;

View 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:

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

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