From: Martin v. Löwis Date: Fri, 18 Apr 2003 11:21:22 +0000 (+0000) Subject: Patch #711835: Remove unnecessary lock operations. X-Git-Tag: v2.2.3c1~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b15021ed010bf53b88a9f8015b22fa53362f5782;p=thirdparty%2FPython%2Fcpython.git Patch #711835: Remove unnecessary lock operations. --- diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index a7ae538e5cf5..d4cc29289a5d 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -359,27 +359,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;