diff -r 6ccb04c4cbae Python/thread_pthread.h --- a/Python/thread_pthread.h Fri Sep 28 01:15:39 2012 -0700 +++ b/Python/thread_pthread.h Fri Sep 28 11:46:47 2012 +0100 @@ -142,7 +142,7 @@ pthread_mutex_t mut; } pthread_lock; -#define CHECK_STATUS(name) if (status != 0) { perror(name); error = 1; } +#define CHECK_STATUS(name) if (status != 0) { perror(name); } /* * Initialization. @@ -275,7 +275,7 @@ PyThread_allocate_lock(void) { sem_t *lock; - int status, error = 0; + int status; dprintf(("PyThread_allocate_lock called\n")); if (!initialized) @@ -287,7 +287,7 @@ status = sem_init(lock,0,1); CHECK_STATUS("sem_init"); - if (error) { + if (status != 0) { free((void *)lock); lock = NULL; } @@ -301,7 +301,7 @@ PyThread_free_lock(PyThread_type_lock lock) { sem_t *thelock = (sem_t *)lock; - int status, error = 0; + int status; dprintf(("PyThread_free_lock(%p) called\n", lock)); @@ -332,7 +332,7 @@ { PyLockStatus success; sem_t *thelock = (sem_t *)lock; - int status, error = 0; + int status; struct timespec ts; dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n", @@ -383,7 +383,7 @@ PyThread_release_lock(PyThread_type_lock lock) { sem_t *thelock = (sem_t *)lock; - int status, error = 0; + int status; dprintf(("PyThread_release_lock(%p) called\n", lock)); @@ -414,6 +414,7 @@ status = pthread_mutex_init(&lock->mut, pthread_mutexattr_default); CHECK_STATUS("pthread_mutex_init"); + error |= status; /* Mark the pthread mutex underlying a Python mutex as pure happens-before. We can't simply mark the Python-level mutex as a mutex because it can be @@ -424,8 +425,9 @@ status = pthread_cond_init(&lock->lock_released, pthread_condattr_default); CHECK_STATUS("pthread_cond_init"); + error |= status; - if (error) { + if (error != 0) { free((void *)lock); lock = 0; } @@ -439,7 +441,7 @@ PyThread_free_lock(PyThread_type_lock lock) { pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; + int status; dprintf(("PyThread_free_lock(%p) called\n", lock)); @@ -461,7 +463,7 @@ { PyLockStatus success; pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; + int status; dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n", lock, microseconds, intr_flag)); @@ -515,7 +517,7 @@ status = pthread_mutex_unlock( &thelock->mut ); CHECK_STATUS("pthread_mutex_unlock[1]"); - if (error) success = PY_LOCK_FAILURE; + if (status != 0) success = PY_LOCK_FAILURE; dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n", lock, microseconds, intr_flag, success)); return success; @@ -525,7 +527,7 @@ PyThread_release_lock(PyThread_type_lock lock) { pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; + int status; dprintf(("PyThread_release_lock(%p) called\n", lock));