From bde3b0335bb2462c392d9ddc067e3856de682bbc Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Fri, 30 Aug 2002 23:55:51 +0000 Subject: [PATCH] Checked in an equivalent but simpler fix for Bug 165639 (NSSRWLock_UnlockWrite failed to wake up waiting readers). --- security/nss/lib/util/nssrwlk.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/security/nss/lib/util/nssrwlk.c b/security/nss/lib/util/nssrwlk.c index cc548bd1ce3..33aaaa71324 100644 --- a/security/nss/lib/util/nssrwlk.c +++ b/security/nss/lib/util/nssrwlk.c @@ -331,18 +331,13 @@ NSSRWLock_UnlockWrite(NSSRWLock *rwlock) rwlock->rw_owner = NULL; /* I don't own it any more. */ - if (rwlock->rw_reader_locks == 0) { /* no readers, wake up somebody. */ - /* Give preference to waiting writers. */ - if (rwlock->rw_waiting_writers > 0) + /* Give preference to waiting writers. */ + if (rwlock->rw_waiting_writers > 0) { + if (rwlock->rw_reader_locks == 0) PZ_NotifyCondVar(rwlock->rw_writer_waitq); - else if (rwlock->rw_waiting_readers > 0) - PZ_NotifyAllCondVar(rwlock->rw_reader_waitq); - } else { - /* Give preference to waiting writers. */ - if ( rwlock->rw_waiting_writers == 0 && - rwlock->rw_waiting_readers > 0) - PZ_NotifyAllCondVar(rwlock->rw_reader_waitq); - } + } else if (rwlock->rw_waiting_readers > 0) { + PZ_NotifyAllCondVar(rwlock->rw_reader_waitq); + } } PZ_Unlock(rwlock->rw_lock);