mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-21 01:32:09 +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
fa88f3952d
commit
28a0563098
@ -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…
x
Reference in New Issue
Block a user