- In rw_wunlock_hard prefer to wakeup writers if there are both readers

and writers available.  Doing otherwise can cause deadlocks as no
   read locks can proceed while there are write waiters.

Sponsored by:	Nokia
This commit is contained in:
Jeff Roberson 2008-02-07 06:16:54 +00:00
parent fb73a5ab6c
commit 0fef2c50b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176076

View File

@ -679,11 +679,11 @@ _rw_wunlock_hard(struct rwlock *rw, uintptr_t tid, const char *file, int line)
* of waiters or doing some complicated lock handoff gymnastics.
*/
v = RW_UNLOCKED;
if (rw->rw_lock & RW_LOCK_READ_WAITERS) {
queue = TS_SHARED_QUEUE;
v |= (rw->rw_lock & RW_LOCK_WRITE_WAITERS);
} else
if (rw->rw_lock & RW_LOCK_WRITE_WAITERS) {
queue = TS_EXCLUSIVE_QUEUE;
v |= (rw->rw_lock & RW_LOCK_READ_WAITERS);
} else
queue = TS_SHARED_QUEUE;
/* Wake up all waiters for the specific queue. */
if (LOCK_LOG_TEST(&rw->lock_object, 0))