diff --git a/glib/gwakeup.c b/glib/gwakeup.c index 0f76be62b..582b2aa34 100644 --- a/glib/gwakeup.c +++ b/glib/gwakeup.c @@ -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. */ diff --git a/glib/tests/gwakeuptest.c b/glib/tests/gwakeuptest.c index b37fb43fc..ab36c858a 100644 --- a/glib/tests/gwakeuptest.c +++ b/glib/tests/gwakeuptest.c @@ -1,12 +1,5 @@ #include #include -#ifdef G_OS_UNIX -#include -#endif - -#ifdef _WIN32 -static void alarm (int sec) { } -#endif static gboolean check_signaled (GWakeup *wakeup) @@ -32,9 +25,6 @@ test_semantics (void) GWakeup *wakeup; gint i; - /* prevent the test from deadlocking */ - alarm (60); - wakeup = g_wakeup_new (); g_assert (!check_signaled (wakeup)); @@ -66,9 +56,6 @@ test_semantics (void) g_assert (!check_signaled (wakeup)); g_wakeup_free (wakeup); - - /* cancel the alarm */ - alarm (0); } struct token @@ -213,9 +200,6 @@ test_threaded (void) { gint i; - /* make sure we don't block forever */ - alarm (60); - /* simple mainloop test based on GWakeup. * * create a bunch of contexts and a thread to 'run' each one. create @@ -252,9 +236,6 @@ test_threaded (void) } g_wakeup_free (last_token_wakeup); - - /* cancel alarm */ - alarm (0); } int