winxp threads: fix some condition variable races
authorRyan Lortie <desrt@desrt.ca>
Mon, 19 Dec 2011 22:35:31 +0000 (17:35 -0500)
committerRyan Lortie <desrt@desrt.ca>
Mon, 19 Dec 2011 22:40:08 +0000 (17:40 -0500)
commit541693f42d462f114055fd05d1ac536e0c6f46f5
treec6aefe3e41c5f5ed95e5d13c9f807eeaceff55f3
parentf3cf8c0ca8ea952c08ef29af1e84515a8f6a2d77
winxp threads: fix some condition variable races

There are some races in the condition variable emulation code for
Windows XP with respect to timeouts while waiting.

First, in the event of a timeout, we never remove the waiter from the
condition variable.  This can cause crashes later.  That problem was
found by Rodrigo Rivas Costa.

Second, if the waiting thread times out and exits just as we were about
to call SetEvent() on its waiter event, we could end up trying to access
the waiter after it was closed/freed.  We need to hold on to the lock a
little bit longer to ensure that that's not possible.

https://bugzilla.gnome.org/show_bug.cgi?id=666551
glib/gthread-win32.c