Checked in an equivalent but simpler fix for Bug 165639
authorwtc%netscape.com
Fri, 30 Aug 2002 23:55:51 +0000
changeset 3522 0ed4d96eafbf4ebae38fdf1bcb6cde5e4c3812bb
parent 3521 e97372ffc4f7d542b45e4f356fd160c7d3e5e05b
child 3523 8d71d58990fde33986c57b6f4c12746468c4b67b
push idunknown
push userunknown
push dateunknown
bugs165639
Checked in an equivalent but simpler fix for Bug 165639 (NSSRWLock_UnlockWrite failed to wake up waiting readers).
security/nss/lib/util/nssrwlk.c
--- a/security/nss/lib/util/nssrwlk.c
+++ b/security/nss/lib/util/nssrwlk.c
@@ -326,28 +326,23 @@ NSSRWLock_UnlockWrite(NSSRWLock *rwlock)
     PR_ASSERT(rwlock->rw_writer_locks > 0); /* lock must be write locked */
 
     if (  rwlock->rw_owner        == me  &&	/* I own it, and            */
           rwlock->rw_writer_locks  > 0   &&	/* I own it, and            */
         --rwlock->rw_writer_locks == 0) {	/* I'm all done with it     */
 
 	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);
 
 #ifdef NSS_RWLOCK_RANK_ORDER_DEBUG
     /*
      * update thread's lock rank
      */
     nssRWLock_UnsetThreadRank(me, rwlock);