mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-23 06:06:54 +00:00
MINOR: fd: make fd_clr_running() return the previous value instead
It's an AND so it destroys information and due to this there's a call place where we have to perform two reads to know the previous value then to change it. With a fetch-and-and instead, in a single operation we can know if the bit was previously present, which is more efficient.
This commit is contained in:
parent
a707d02657
commit
d6e1987612
@ -408,12 +408,12 @@ static inline ulong fd_get_running(int fd, uint desired_tgid)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove tid_bit from the fd's running mask and returns the bits that remain
|
/* remove tid_bit from the fd's running mask and returns the value before the
|
||||||
* after the atomic operation.
|
* atomic operation, so that the caller can know if it was present.
|
||||||
*/
|
*/
|
||||||
static inline long fd_clr_running(int fd)
|
static inline long fd_clr_running(int fd)
|
||||||
{
|
{
|
||||||
return _HA_ATOMIC_AND_FETCH(&fdtab[fd].running_mask, ~ti->ltid_bit);
|
return _HA_ATOMIC_FETCH_AND(&fdtab[fd].running_mask, ~ti->ltid_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepares <fd> for being polled on all permitted threads of this group ID
|
/* Prepares <fd> for being polled on all permitted threads of this group ID
|
||||||
|
5
src/fd.c
5
src/fd.c
@ -378,7 +378,7 @@ void fd_delete(int fd)
|
|||||||
|
|
||||||
HA_ATOMIC_OR(&fdtab[fd].running_mask, ti->ltid_bit);
|
HA_ATOMIC_OR(&fdtab[fd].running_mask, ti->ltid_bit);
|
||||||
HA_ATOMIC_STORE(&fdtab[fd].thread_mask, 0);
|
HA_ATOMIC_STORE(&fdtab[fd].thread_mask, 0);
|
||||||
if (fd_clr_running(fd) == 0)
|
if (fd_clr_running(fd) == ti->ltid_bit)
|
||||||
_fd_delete_orphan(fd);
|
_fd_delete_orphan(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,8 +594,7 @@ int fd_update_events(int fd, uint evts)
|
|||||||
* This is detected by both thread_mask and running_mask being 0 after
|
* This is detected by both thread_mask and running_mask being 0 after
|
||||||
* we remove ourselves last.
|
* we remove ourselves last.
|
||||||
*/
|
*/
|
||||||
if ((fdtab[fd].running_mask & ti->ltid_bit) &&
|
if (fd_clr_running(fd) == ti->ltid_bit && !fdtab[fd].thread_mask) {
|
||||||
fd_clr_running(fd) == 0 && !fdtab[fd].thread_mask) {
|
|
||||||
_fd_delete_orphan(fd);
|
_fd_delete_orphan(fd);
|
||||||
return FD_UPDT_CLOSED;
|
return FD_UPDT_CLOSED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user