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.
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user