diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index dbb152639..454b756cd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2003-04-15 Thomas Pfaff + + * 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. + 2003-04-13 Pierre Humblet * mkvers.sh: Prefix day with 0 in date only when day < 10. diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 0eadd03c5..5f0917ad6 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1210,13 +1210,7 @@ pthread_rwlock::unlock () delete reader; } - if (waiting_writers) - { - if (!readers) - cond_writers.unblock (false); - } - else if (waiting_readers) - cond_readers.unblock (true); + release (); DONE: mtx.unlock (); @@ -1263,6 +1257,7 @@ pthread_rwlock::rdlock_cleanup (void *arg) pthread_rwlock *rwlock = (pthread_rwlock *) arg; --(rwlock->waiting_readers); + rwlock->release (); rwlock->mtx.unlock (); } @@ -1272,6 +1267,7 @@ pthread_rwlock::wrlock_cleanup (void *arg) pthread_rwlock *rwlock = (pthread_rwlock *) arg; --(rwlock->waiting_writers); + rwlock->release (); rwlock->mtx.unlock (); } diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 05638d9c6..121d35af9 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);