From b87c55f6ed83e11a483f43d6bc29a9d4a79c786f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sun, 27 Jul 2014 03:06:16 +0000 Subject: [PATCH] poll: Prevent false-negative from WAKE_EVENT() on W32 SetEvent() seems to not call SetLastError(0) internally, so checking last error after calling SetEvent() may return the error from an earlier W32 API call. Fix this by calling SetlastError(0) explicitly. Currently WAKE_EVENT() code is cramped into a macro and doesn't look to be entirely correct. Particularly, it does not check the return value of SetEvent(), only the thread-local W32 error value. It is likely that SetEvent() actually just returns non-zero value, but the code mistakenly thinks that the call has failed, because GetLastError() seems to indicate so. https://bugzilla.gnome.org/show_bug.cgi?id=733805 --- gst/gstpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/gstpoll.c b/gst/gstpoll.c index 34f93f4..04165a5 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -170,7 +170,7 @@ static gboolean gst_poll_add_fd_unlocked (GstPoll * set, GstPollFD * fd); #define WAKE_EVENT(s) (write ((s)->control_write_fd.fd, "W", 1) == 1) #define RELEASE_EVENT(s) (read ((s)->control_read_fd.fd, (s)->buf, 1) == 1) #else -#define WAKE_EVENT(s) (SetEvent ((s)->wakeup_event), errno = GetLastError () == NO_ERROR ? 0 : EACCES, errno == 0 ? 1 : 0) +#define WAKE_EVENT(s) (SetLastError (0), SetEvent ((s)->wakeup_event), errno = GetLastError () == NO_ERROR ? 0 : EACCES, errno == 0 ? 1 : 0) #define RELEASE_EVENT(s) (ResetEvent ((s)->wakeup_event)) #endif -- 2.7.4