summaryrefslogtreecommitdiff
path: root/Python/thread_pthread.h
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-04-18 11:11:09 +0000
committerMartin v. Löwis <martin@v.loewis.de>2003-04-18 11:11:09 +0000
commit49c8a063d2db72232ab22809ff8741232e7523df (patch)
tree833ddfd2dad82fe9650b4a9e414c2b160058decd /Python/thread_pthread.h
parent5845337c7d3f2c5397fd1c1184d9085877ca4e34 (diff)
downloadcpython-49c8a063d2db72232ab22809ff8741232e7523df.tar.gz
Patch #711835: Remove unnecessary lock operations. Will backport to 2.2.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r--Python/thread_pthread.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index e30982fc4f..2596af55c6 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -497,27 +497,23 @@ PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
status = pthread_mutex_lock( &thelock->mut );
CHECK_STATUS("pthread_mutex_lock[1]");
success = thelock->locked == 0;
- if (success) thelock->locked = 1;
- status = pthread_mutex_unlock( &thelock->mut );
- CHECK_STATUS("pthread_mutex_unlock[1]");
if ( !success && waitflag ) {
/* continue trying until we get the lock */
/* mut must be locked by me -- part of the condition
* protocol */
- status = pthread_mutex_lock( &thelock->mut );
- CHECK_STATUS("pthread_mutex_lock[2]");
while ( thelock->locked ) {
status = pthread_cond_wait(&thelock->lock_released,
&thelock->mut);
CHECK_STATUS("pthread_cond_wait");
}
- thelock->locked = 1;
- status = pthread_mutex_unlock( &thelock->mut );
- CHECK_STATUS("pthread_mutex_unlock[2]");
success = 1;
}
+ if (success) thelock->locked = 1;
+ status = pthread_mutex_unlock( &thelock->mut );
+ CHECK_STATUS("pthread_mutex_unlock[1]");
+
if (error) success = 0;
dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;