summaryrefslogtreecommitdiff
path: root/Python/thread_pthread.h
diff options
context:
space:
mode:
authorKristj?n Valur J?nsson <kristjan@ccpgames.com>2012-06-05 22:17:42 +0000
committerKristj?n Valur J?nsson <kristjan@ccpgames.com>2012-06-05 22:17:42 +0000
commit8bfa3df4bcf0163ddbae0557227e73c4ff4eef09 (patch)
tree06ea31e52ea9328e31db2901ae00ef29e358a4f6 /Python/thread_pthread.h
parenta3f597145efb7bf83193f2b1d6568c43fb09873a (diff)
downloadcpython-8bfa3df4bcf0163ddbae0557227e73c4ff4eef09.tar.gz
Signal condition variables with the mutex held. Destroy condition variables
before their mutexes.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r--Python/thread_pthread.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 4f9e2c19d6..5007aaf0b7 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -443,12 +443,15 @@ PyThread_free_lock(PyThread_type_lock lock)
dprintf(("PyThread_free_lock(%p) called\n", lock));
- status = pthread_mutex_destroy( &thelock->mut );
- CHECK_STATUS("pthread_mutex_destroy");
-
+ /* 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");
+
free((void *)thelock);
}
@@ -531,12 +534,12 @@ PyThread_release_lock(PyThread_type_lock lock)
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 */