mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gwakeup: Be consistent in reading the same data we wrote
During acknowledge read the same quantity we wrote (and expected by eventfd) instead of always reading just 16 bytes.
This commit is contained in:
parent
345e5bcf2c
commit
94b658ab4c
@ -206,10 +206,20 @@ g_wakeup_get_pollfd (GWakeup *wakeup,
|
||||
void
|
||||
g_wakeup_acknowledge (GWakeup *wakeup)
|
||||
{
|
||||
char buffer[16];
|
||||
|
||||
/* read until it is empty */
|
||||
while (read (wakeup->fds[0], buffer, sizeof buffer) == sizeof buffer);
|
||||
|
||||
if (wakeup->fds[1] == -1)
|
||||
{
|
||||
uint64_t value;
|
||||
|
||||
while (read (wakeup->fds[0], &value, sizeof (value)) == sizeof (value));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
while (read (wakeup->fds[0], &value, sizeof (value)) == sizeof (value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +243,7 @@ g_wakeup_signal (GWakeup *wakeup)
|
||||
|
||||
if (wakeup->fds[1] == -1)
|
||||
{
|
||||
guint64 one = 1;
|
||||
uint64_t one = 1;
|
||||
|
||||
/* eventfd() case. It requires a 64-bit counter increment value to be
|
||||
* written. */
|
||||
@ -243,7 +253,7 @@ g_wakeup_signal (GWakeup *wakeup)
|
||||
}
|
||||
else
|
||||
{
|
||||
guint8 one = 1;
|
||||
uint8_t one = 1;
|
||||
|
||||
/* Non-eventfd() case. Only a single byte needs to be written, and it can
|
||||
* have an arbitrary value. */
|
||||
|
Loading…
Reference in New Issue
Block a user