diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-25 15:08:59 +0100 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-25 15:08:59 +0100 |
commit | 9b927cf3cac4cf0f7843e0a3f9e9647a13f0c54a (patch) | |
tree | e026f97ceb8431d03d2f4e0340d11ddb4b19ad1f /glib/gwakeup.c | |
parent | 73d39c11a0c085416cc55df47f9c3fdaa8149c6b (diff) | |
download | glib-9b927cf3cac4cf0f7843e0a3f9e9647a13f0c54a.tar.gz glib-9b927cf3cac4cf0f7843e0a3f9e9647a13f0c54a.tar.bz2 glib-9b927cf3cac4cf0f7843e0a3f9e9647a13f0c54a.zip |
Imported Upstream version 2.78.4upstream
Diffstat (limited to 'glib/gwakeup.c')
-rw-r--r-- | glib/gwakeup.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/glib/gwakeup.c b/glib/gwakeup.c index 24d85b669..6ce401e52 100644 --- a/glib/gwakeup.c +++ b/glib/gwakeup.c @@ -160,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, O_CLOEXEC | O_NONBLOCK, &error)) g_error ("Creating pipes for GWakeup: %s", error->message); if (!g_unix_set_fd_nonblocking (wakeup->fds[0], TRUE, &error) || @@ -207,19 +207,25 @@ g_wakeup_get_pollfd (GWakeup *wakeup, void g_wakeup_acknowledge (GWakeup *wakeup) { - /* read until it is empty */ + int res; if (wakeup->fds[1] == -1) { uint64_t value; - while (read (wakeup->fds[0], &value, sizeof (value)) == sizeof (value)); + /* eventfd() read resets counter */ + do + res = read (wakeup->fds[0], &value, sizeof (value)); + while (G_UNLIKELY (res == -1 && errno == EINTR)); } else { uint8_t value; - while (read (wakeup->fds[0], &value, sizeof (value)) == sizeof (value)); + /* read until it is empty */ + do + res = read (wakeup->fds[0], &value, sizeof (value)); + while (res == sizeof (value) || G_UNLIKELY (res == -1 && errno == EINTR)); } } |