Minimize spurious notifications when interrupts are blocked.
authorsrinivas%netscape.com
Fri, 24 Dec 1999 01:05:42 +0000
changeset 1018 d688eb5ba3818c47899c6fd0ac0ea04d2be3a8b5
parent 1017 a7c10fe86ccc290297c0e89caf14706a06075b7d
child 1019 ae5c0729dc4975848f9787e54138305610720bdb
push idunknown
push userunknown
push dateunknown
bugs17055
Minimize spurious notifications when interrupts are blocked. Bugzilla #17055.
pr/src/pthreads/ptthread.c
pr/src/threads/prcthr.c
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -652,17 +652,17 @@ PR_IMPLEMENT(PRStatus) PR_Interrupt(PRTh
     */
     PRCondVar *cv;
     PR_ASSERT(NULL != thred);
     if (NULL == thred) return PR_FAILURE;
 
     thred->state |= PT_THREAD_ABORTED;
 
     cv = thred->waiting;
-    if (NULL != cv)
+    if ((NULL != cv) && !thred->interrupt_blocked)
     {
         PRIntn rv = pthread_cond_broadcast(&cv->cv);
         PR_ASSERT(0 == rv);
     }
     return PR_SUCCESS;
 }  /* PR_Interrupt */
 
 PR_IMPLEMENT(void) PR_ClearInterrupt()
--- a/pr/src/threads/prcthr.c
+++ b/pr/src/threads/prcthr.c
@@ -166,17 +166,17 @@ PR_IMPLEMENT(PRStatus) PR_Interrupt(PRTh
 {
 #ifdef _PR_GLOBAL_THREADS_ONLY
     PRCondVar *victim;
 
     _PR_THREAD_LOCK(thread);
     thread->flags |= _PR_INTERRUPT;
     victim = thread->wait.cvar;
     _PR_THREAD_UNLOCK(thread);
-    if (NULL != victim) {
+    if ((NULL != victim) && !thread->interrupt_blocked) {
         int haveLock = (victim->lock->owner == _PR_MD_CURRENT_THREAD());
 
         if (!haveLock) PR_Lock(victim->lock);
         PR_NotifyAllCondVar(victim);
         if (!haveLock) PR_Unlock(victim->lock);
     }
     return PR_SUCCESS;
 #else  /* ! _PR_GLOBAL_THREADS_ONLY */
@@ -189,26 +189,28 @@ PR_IMPLEMENT(PRStatus) PR_Interrupt(PRTh
             _PR_THREAD_LOCK(thread);
             thread->flags |= _PR_INTERRUPT;
         switch (thread->state) {
                 case _PR_COND_WAIT:
                         /*
                          * call is made with thread locked;
                          * on return lock is released
                          */
-                        _PR_NotifyLockedThread(thread);
+						if (!thread->interrupt_blocked)
+                        	_PR_NotifyLockedThread(thread);
                         break;
                 case _PR_IO_WAIT:
                         /*
                          * Need to hold the thread lock when calling
                          * _PR_Unblock_IO_Wait().  On return lock is
                          * released. 
                          */
 #if defined(XP_UNIX) || defined(WINNT) || defined(WIN16)
-                        _PR_Unblock_IO_Wait(thread);
+						if (!thread->interrupt_blocked)
+                        	_PR_Unblock_IO_Wait(thread);
 #else
                         _PR_THREAD_UNLOCK(thread);
 #endif
                         break;
                 case _PR_RUNNING:
                 case _PR_RUNNABLE:
                 case _PR_LOCK_WAIT:
                 default: