diff options
Diffstat (limited to 'glib/gwakeup.c')
-rw-r--r-- | glib/gwakeup.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/glib/gwakeup.c b/glib/gwakeup.c index 0f76be62b..a3283a3ff 100644 --- a/glib/gwakeup.c +++ b/glib/gwakeup.c @@ -21,6 +21,7 @@ #include "config.h" +#include <stdint.h> /* gwakeup.c is special -- GIO and some test cases include it. As such, * it cannot include other glib headers without triggering the single @@ -159,7 +160,7 @@ g_wakeup_new (void) /* for any failure, try a pipe instead */ #endif - if (!g_unix_open_pipe (wakeup->fds, FD_CLOEXEC, &error)) + if (!g_unix_open_pipe (wakeup->fds, FD_CLOEXEC | O_NONBLOCK, &error)) g_error ("Creating pipes for GWakeup: %s", error->message); if (!g_unix_set_fd_nonblocking (wakeup->fds[0], TRUE, &error) || @@ -206,10 +207,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 +244,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 +254,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. */ |