diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-01 13:31:12 +0200 |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-01 13:31:12 +0200 |
commit | c83af6a2bda3609c435b6ce84f990256c593f3d4 (patch) | |
tree | 189c44827c3dba1a46ad12187f3dea03c549798f /Python/thread_pthread.h | |
parent | 7afede10a583e241aea0452c8bc9fe7522509873 (diff) | |
parent | 9e9e8c4bbb70e717829906215e42e2c398f28679 (diff) | |
download | cpython-c83af6a2bda3609c435b6ce84f990256c593f3d4.tar.gz |
Merge issue #16373: Prevent infinite recursion for ABC Set class operations.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r-- | Python/thread_pthread.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 3cde03567c..5007aaf0b7 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -148,7 +148,7 @@ typedef struct { * Initialization. */ -#ifdef _HAVE_BSDI +#if defined(_HAVE_BSDI) static void _noop(void) { @@ -244,8 +244,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) hosed" because: - It does not guarantee the promise that a non-zero integer is returned. - The cast to long is inherently unsafe. - - It is not clear that the 'volatile' (for AIX?) and ugly casting in the - latter return statement (for Alpha OSF/1) are any longer necessary. + - It is not clear that the 'volatile' (for AIX?) are any longer necessary. */ long PyThread_get_thread_ident(void) @@ -253,13 +252,8 @@ PyThread_get_thread_ident(void) volatile pthread_t threadid; if (!initialized) PyThread_init_thread(); - /* Jump through some hoops for Alpha OSF/1 */ threadid = pthread_self(); -#if SIZEOF_PTHREAD_T <= SIZEOF_LONG return (long) threadid; -#else - return (long) *(long *) &threadid; -#endif } void @@ -449,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); } @@ -537,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 */ |