mirror of
https://github.com/python/cpython.git
synced 2025-10-22 06:32:43 +00:00
Patch #711835: Remove unnecessary lock operations. Will backport to 2.2.
This commit is contained in:
parent
6920652823
commit
1509a152b3
1 changed files with 4 additions and 8 deletions
|
@ -497,27 +497,23 @@ PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
|
||||||
status = pthread_mutex_lock( &thelock->mut );
|
status = pthread_mutex_lock( &thelock->mut );
|
||||||
CHECK_STATUS("pthread_mutex_lock[1]");
|
CHECK_STATUS("pthread_mutex_lock[1]");
|
||||||
success = thelock->locked == 0;
|
success = thelock->locked == 0;
|
||||||
if (success) thelock->locked = 1;
|
|
||||||
status = pthread_mutex_unlock( &thelock->mut );
|
|
||||||
CHECK_STATUS("pthread_mutex_unlock[1]");
|
|
||||||
|
|
||||||
if ( !success && waitflag ) {
|
if ( !success && waitflag ) {
|
||||||
/* continue trying until we get the lock */
|
/* continue trying until we get the lock */
|
||||||
|
|
||||||
/* mut must be locked by me -- part of the condition
|
/* mut must be locked by me -- part of the condition
|
||||||
* protocol */
|
* protocol */
|
||||||
status = pthread_mutex_lock( &thelock->mut );
|
|
||||||
CHECK_STATUS("pthread_mutex_lock[2]");
|
|
||||||
while ( thelock->locked ) {
|
while ( thelock->locked ) {
|
||||||
status = pthread_cond_wait(&thelock->lock_released,
|
status = pthread_cond_wait(&thelock->lock_released,
|
||||||
&thelock->mut);
|
&thelock->mut);
|
||||||
CHECK_STATUS("pthread_cond_wait");
|
CHECK_STATUS("pthread_cond_wait");
|
||||||
}
|
}
|
||||||
thelock->locked = 1;
|
|
||||||
status = pthread_mutex_unlock( &thelock->mut );
|
|
||||||
CHECK_STATUS("pthread_mutex_unlock[2]");
|
|
||||||
success = 1;
|
success = 1;
|
||||||
}
|
}
|
||||||
|
if (success) thelock->locked = 1;
|
||||||
|
status = pthread_mutex_unlock( &thelock->mut );
|
||||||
|
CHECK_STATUS("pthread_mutex_unlock[1]");
|
||||||
|
|
||||||
if (error) success = 0;
|
if (error) success = 0;
|
||||||
dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue