diff options
| author | rpj <rpj> | 2002-09-20 02:35:51 +0000 | 
|---|---|---|
| committer | rpj <rpj> | 2002-09-20 02:35:51 +0000 | 
| commit | 5ef5ad3390c967520922b99b130ed6339aa3a8d6 (patch) | |
| tree | 93c70af299db5bb52f8bf4c370d4edf2b3458b7c | |
| parent | 6ae85d969228650bd4cf432bd4d6dcd959bf1a59 (diff) | |
2002-09-20  Michael Johnson  <michaelj@maine.rr.com>
        * pthread_cond_destroy.c (pthread_cond_destroy):
        When two different threads exist, and one is attempting to
        destroy a condition variable while the other is attempting to
        initialize a condition variable that was created with
        PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink
        the ptw32_cond_list_lock critical section to fix it.
| -rw-r--r-- | CONTRIBUTORS | 2 | ||||
| -rw-r--r-- | ChangeLog | 9 | ||||
| -rw-r--r-- | pthread_cond_destroy.c | 8 | 
3 files changed, 15 insertions, 4 deletions
| diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 513b637..78bb7a1 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -98,3 +98,5 @@ Max Woodbury		mtew@cds.duke.edu  					reduced namespace pollution;
  					idea to separate routines to reduce statically
  					linked image sizes.
 +Michael Johnson		michaelj@maine.rr.com
 +					Bug fix.
 @@ -1,3 +1,12 @@ +2002-09-20  Michael Johnson  <michaelj@maine.rr.com> + +	* pthread_cond_destroy.c (pthread_cond_destroy):  +	When two different threads exist, and one is attempting to +	destroy a condition variable while the other is attempting to +	initialize a condition variable that was created with +	PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink +	the ptw32_cond_list_lock critical section to fix it. +  2002-07-31  Ross Johnson  <rpj@special.ise.canberra.edu.au>  	* ptw32_threadStart.c (ptw32_threadStart): Thread cancelLock diff --git a/pthread_cond_destroy.c b/pthread_cond_destroy.c index 9c4a214..79a0020 100644 --- a/pthread_cond_destroy.c +++ b/pthread_cond_destroy.c @@ -126,10 +126,10 @@ pthread_cond_destroy (pthread_cond_t * cond)        return EINVAL;      } -  EnterCriticalSection(&ptw32_cond_list_lock); -    if (*cond != PTHREAD_COND_INITIALIZER)      { +      EnterCriticalSection(&ptw32_cond_list_lock); +        cv = *cond;        /* @@ -207,6 +207,8 @@ pthread_cond_destroy (pthread_cond_t * cond)            (void) free(cv);          } + +      LeaveCriticalSection(&ptw32_cond_list_lock);      }    else      { @@ -240,7 +242,5 @@ pthread_cond_destroy (pthread_cond_t * cond)        LeaveCriticalSection(&ptw32_cond_test_init_lock);      } -  LeaveCriticalSection(&ptw32_cond_list_lock); -    return ((result != 0) ? result : ((result1 != 0) ? result1 : result2));  } | 
