mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-20 16:01:10 +08:00
2002-05-02 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (__pthread_cond_dowait): Fix a race on signalling from a thread woken by the same condition variable it's signalling on. Thanks to Michael Beach for the report and test case.
This commit is contained in:
parent
4c956a7c0f
commit
37143995da
@ -1,3 +1,9 @@
|
||||
2002-05-02 Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
* thread.cc (__pthread_cond_dowait): Fix a race on signalling from a
|
||||
thread woken by the same condition variable it's signalling on. Thanks
|
||||
to Michael Beach for the report and test case.
|
||||
|
||||
2002-05-02 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* path.h (pathconv_arg): Add PC_POSIX.
|
||||
@ -44,6 +50,7 @@ Wed May 1 16:06:02 2002 Jason Tishler <jason@tishler.net>
|
||||
|
||||
* include/cygwin/types.h: Include <sys/sysmacros.h>.
|
||||
|
||||
>>>>>>> 1.1179
|
||||
Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
|
||||
|
||||
* security.cc (get_lsa_srv_inf): Prevent extraneous backslashes for
|
||||
|
@ -1791,20 +1791,22 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
InterlockedIncrement (&((*themutex)->condwaits));
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %p", *cond);
|
||||
/* At this point calls to Signal will progress evebn if we aren' yet waiting
|
||||
* However, the loop there should allow us to get scheduled and call wait,
|
||||
* and have them call PulseEvent again if we dont' respond.
|
||||
*/
|
||||
rv = (*cond)->TimedWait (waitlength);
|
||||
/* this may allow a race on the mutex acquisition and waits..
|
||||
* But doing this within the cond access mutex creates a different race
|
||||
*/
|
||||
bool last = false;
|
||||
if (InterlockedDecrement (&((*cond)->waiting)) == 0)
|
||||
last = true;
|
||||
InterlockedDecrement (&((*cond)->waiting));
|
||||
/* Tell Signal that we have been released */
|
||||
InterlockedDecrement (&((*cond)->ExitingWait));
|
||||
(*themutex)->Lock ();
|
||||
if (last == true)
|
||||
(*cond)->mutex = NULL;
|
||||
if (pthread_mutex_lock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to lock condition variable access mutex, this %p", *cond);
|
||||
if ((*cond)->waiting == 0)
|
||||
(*cond)->mutex = NULL;
|
||||
InterlockedDecrement (&((*themutex)->condwaits));
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %p", *cond);
|
||||
|
Loading…
x
Reference in New Issue
Block a user