From cb2316aaa1adc1f80498141d51467a850cde5fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sat, 29 Jul 2017 07:56:19 +0000 Subject: [PATCH] glib/gpoll W32: use WFSOE() instead of SleepEx() WaitForSingleObjectEx() is supposed to be a more efficient sleep method. It waits on the handle of the current process. That handle will be signaled once the process terminates, and since we're *inside* the process, it'll never happen (and if it does, we won't care anymore). The use of an alertable wait ensures that we wake up when a completion routine wants to run. https://bugzilla.gnome.org/show_bug.cgi?id=785468 --- glib/gpoll.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/glib/gpoll.c b/glib/gpoll.c index b6c83d8ed..694f1f9a1 100644 --- a/glib/gpoll.c +++ b/glib/gpoll.c @@ -164,10 +164,11 @@ poll_rest (gboolean poll_msgs, if (timeout == INFINITE) ready = WAIT_FAILED; else - { - SleepEx (timeout, TRUE); - ready = WAIT_TIMEOUT; - } + { + /* Wait for the current process to die, more efficient than SleepEx(). */ + WaitForSingleObjectEx (GetCurrentProcess (), timeout, TRUE); + ready = WAIT_TIMEOUT; + } } else {