diff --git a/libtransmission/platform.c b/libtransmission/platform.c index e6e63e4e7..1c7918ddd 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -231,22 +231,11 @@ tr_lockFree( tr_lock * l ) tr_free( l ); } -int -tr_lockTryLock( tr_lock * l ) /* success on zero! */ -{ -#ifdef __BEOS__ - return acquire_sem_etc( l->lock, 1, B_RELATIVE_TIMEOUT, 0 ); -#elif defined(WIN32) - return !TryEnterCriticalSection( &l->lock ); -#else - return pthread_mutex_trylock( &l->lock ); -#endif -} - void tr_lockLock( tr_lock * l ) { - tr_thread_id currentThread = tr_getCurrentThread( ); + const tr_thread_id currentThread = tr_getCurrentThread( ); + if( l->lockThread == currentThread ) { ++l->depth; @@ -260,7 +249,7 @@ tr_lockLock( tr_lock * l ) #else pthread_mutex_lock( &l->lock ); #endif - l->lockThread = tr_getCurrentThread( ); + l->lockThread = currentThread; l->depth = 1; } } diff --git a/libtransmission/platform.h b/libtransmission/platform.h index 60bfee2c3..427e1654d 100644 --- a/libtransmission/platform.h +++ b/libtransmission/platform.h @@ -38,7 +38,6 @@ int tr_amInThread ( const tr_thread * ); tr_lock * tr_lockNew ( void ); void tr_lockFree ( tr_lock * ); -int tr_lockTryLock ( tr_lock * ); void tr_lockLock ( tr_lock * ); void tr_lockUnlock ( tr_lock * ); int tr_lockHave ( const tr_lock * );