Mercurial > cpython-lru_cache-weakref
diff Python/thread_pthread.h @ 77365:6d146e2ae9a9
Signal condition variables with the mutex held. Destroy condition variables
before their mutexes.
| author | Kristján Valur Jónsson <kristjan@ccpgames.com> |
|---|---|
| date | Tue, 05 Jun 2012 22:17:42 +0000 |
| parents | c00ac2b25048 |
| children | 470785a9fdd5 |
line wrap: on
line diff
--- a/Python/thread_pthread.h Tue Jun 05 13:30:24 2012 -0700 +++ b/Python/thread_pthread.h Tue Jun 05 22:17:42 2012 +0000 @@ -443,12 +443,15 @@ dprintf(("PyThread_free_lock(%p) called\n", lock)); + /* some pthread-like implementations tie the mutex to the cond + * and must have the cond destroyed first. + */ + status = pthread_cond_destroy( &thelock->lock_released ); + CHECK_STATUS("pthread_cond_destroy"); + status = pthread_mutex_destroy( &thelock->mut ); CHECK_STATUS("pthread_mutex_destroy"); - status = pthread_cond_destroy( &thelock->lock_released ); - CHECK_STATUS("pthread_cond_destroy"); - free((void *)thelock); } @@ -531,12 +534,12 @@ thelock->locked = 0; - status = pthread_mutex_unlock( &thelock->mut ); - CHECK_STATUS("pthread_mutex_unlock[3]"); - /* wake up someone (anyone, if any) waiting on the lock */ status = pthread_cond_signal( &thelock->lock_released ); CHECK_STATUS("pthread_cond_signal"); + + status = pthread_mutex_unlock( &thelock->mut ); + CHECK_STATUS("pthread_mutex_unlock[3]"); } #endif /* USE_SEMAPHORES */
