]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: fd/poller: turn running_mask to group-local IDs
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Jul 2022 06:16:08 +0000 (08:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 18:16:30 +0000 (20:16 +0200)
From now on, the FD's running_mask only refers to local thread IDs. However,
there remains a limitation, in updt_fd_polling(), we temporarily have to
check and set shared FDs against .thread_mask, which still contains global
ones. As such, nbtgroups > 1 may break (but this is not yet supported without
special build options).

include/haproxy/fd.h
src/fd.c

index 9321777767a04c557acb950b279e5130c802c7c2..9c56fc90ff3486f4972d648088cd6b62bbfb95d7 100644 (file)
@@ -413,7 +413,7 @@ static inline ulong fd_get_running(int fd, uint desired_tgid)
  */
 static inline long fd_clr_running(int fd)
 {
-       return _HA_ATOMIC_AND_FETCH(&fdtab[fd].running_mask, ~tid_bit);
+       return _HA_ATOMIC_AND_FETCH(&fdtab[fd].running_mask, ~ti->ltid_bit);
 }
 
 /* Prepares <fd> for being polled on all permitted threads of this group ID
index 45cc5f46e921e4c0f51ce2cab8e2abd45c098c96..5782349293966fccb3104e2c986cd7a509cb9e25 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -376,7 +376,7 @@ void fd_delete(int fd)
         * safely delete the FD. Most of the time it will be the current thread.
         */
 
-       HA_ATOMIC_OR(&fdtab[fd].running_mask, tid_bit);
+       HA_ATOMIC_OR(&fdtab[fd].running_mask, ti->ltid_bit);
        HA_ATOMIC_STORE(&fdtab[fd].thread_mask, 0);
        if (fd_clr_running(fd) == 0)
                _fd_delete_orphan(fd);
@@ -434,7 +434,7 @@ int fd_takeover(int fd, void *expected_owner)
                return -1;
 
        old = 0;
-       if (!HA_ATOMIC_CAS(&fdtab[fd].running_mask, &old, tid_bit)) {
+       if (!HA_ATOMIC_CAS(&fdtab[fd].running_mask, &old, ti->ltid_bit)) {
                fd_drop_tgid(fd);
                return -1;
        }
@@ -449,7 +449,7 @@ int fd_takeover(int fd, void *expected_owner)
        fd_stop_recv(fd);
 
        /* we're done with it */
-       HA_ATOMIC_AND(&fdtab[fd].running_mask, ~tid_bit);
+       HA_ATOMIC_AND(&fdtab[fd].running_mask, ~ti->ltid_bit);
 
        /* no more changes planned */
        fd_drop_tgid(fd);
@@ -531,7 +531,7 @@ int fd_update_events(int fd, uint evts)
                        fd_drop_tgid(fd);
                        return FD_UPDT_MIGRATED;
                }
-       } while (!HA_ATOMIC_CAS(&fdtab[fd].running_mask, &rmask, rmask | tid_bit));
+       } while (!HA_ATOMIC_CAS(&fdtab[fd].running_mask, &rmask, rmask | ti->ltid_bit));
 
        /* with running we're safe now, we can drop the reference */
        fd_drop_tgid(fd);
@@ -594,7 +594,7 @@ int fd_update_events(int fd, uint evts)
         * This is detected by both thread_mask and running_mask being 0 after
         * we remove ourselves last.
         */
-       if ((fdtab[fd].running_mask & tid_bit) &&
+       if ((fdtab[fd].running_mask & ti->ltid_bit) &&
            fd_clr_running(fd) == 0 && !fdtab[fd].thread_mask) {
                _fd_delete_orphan(fd);
                return FD_UPDT_CLOSED;