aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/thread.h
diff options
context:
space:
mode:
authorThomas Pfaff <tpfaff@gmx.net>2003-04-15 20:14:12 +0000
committerThomas Pfaff <tpfaff@gmx.net>2003-04-15 20:14:12 +0000
commitffb576fbf2440548e717bf7f37b3aafa48ee2fbc (patch)
treeaeb62e60f0b07c0306c3f0e7a5ae7d5a03e216b8 /winsup/cygwin/thread.h
parentcfd2c7bea8bcc4d04a1ace959fed7fd2e1ba3784 (diff)
downloadnewlib-ffb576fbf2440548e717bf7f37b3aafa48ee2fbc.zip
newlib-ffb576fbf2440548e717bf7f37b3aafa48ee2fbc.tar.gz
newlib-ffb576fbf2440548e717bf7f37b3aafa48ee2fbc.tar.bz2
Fix a race in pthread_rwlock caused by simultanoues unlock and cancelation.
* thread.h (pthread_rwlock::release): New method. * thread.cc (pthread_rwlock::unlock): Use release to signal waiting threads. (pthread_rwlock::rdlock_cleanup): Signal waiting threads after a cancelation. (pthread_rwlock::wrlock_cleanup): Ditto.
Diffstat (limited to 'winsup/cygwin/thread.h')
-rw-r--r--winsup/cygwin/thread.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 05638d9..121d35a 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -587,6 +587,18 @@ private:
void remove_reader (struct RWLOCK_READER *rd);
struct RWLOCK_READER *lookup_reader (pthread_t thread);
+ void release ()
+ {
+ if (waiting_writers)
+ {
+ if (!readers)
+ cond_writers.unblock (false);
+ }
+ else if (waiting_readers)
+ cond_readers.unblock (true);
+ }
+
+
static void rdlock_cleanup (void *arg);
static void wrlock_cleanup (void *arg);