Fix for 165639 - NSSRWLock_UnlockWrite causes deadlock when using recursivity of locoks. Fix by Wan-Teh
authorjpierre%netscape.com
Fri, 30 Aug 2002 22:46:45 +0000
changeset 3520 558922d2d6848c39ccf3aa3c5850e741c411f1c7
parent 3519 0ae3c349a90802659fe303e587439f3ab5631b04
child 3521 e97372ffc4f7d542b45e4f356fd160c7d3e5e05b
push idunknown
push userunknown
push dateunknown
bugs165639
Fix for 165639 - NSSRWLock_UnlockWrite causes deadlock when using recursivity of locoks. Fix by Wan-Teh
security/nss/lib/util/nssrwlk.c
--- a/security/nss/lib/util/nssrwlk.c
+++ b/security/nss/lib/util/nssrwlk.c
@@ -332,17 +332,22 @@ 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) 
 		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);
+        }
     }
     PZ_Unlock(rwlock->rw_lock);
 
 #ifdef NSS_RWLOCK_RANK_ORDER_DEBUG
     /*
      * update thread's lock rank
      */
     nssRWLock_UnsetThreadRank(me, rwlock);