mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
wakeup: do single read when using eventfd()
Previously, this would loop as long as read() got the expected number of bytes back, which is 8. That means every successful read() of the eventfd would perform an additional syscall() as a followup. This is not ideal because eventfd (unless used as an EFD_SEMAPHORE) will reset the counter as part of the read(). So that means that we either do an additional throw-away syscall() or potentially race against a producer generating new events before this change.
This commit is contained in:
parent
bd13ec30a9
commit
de79831e3c
@ -213,7 +213,8 @@ g_wakeup_acknowledge (GWakeup *wakeup)
|
||||
{
|
||||
uint64_t value;
|
||||
|
||||
while (read (wakeup->fds[0], &value, sizeof (value)) == sizeof (value));
|
||||
/* eventfd() read resets counter */
|
||||
read (wakeup->fds[0], &value, sizeof (value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user