summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_mutex.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 0127721..925eb27 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -74,6 +74,7 @@ static void bucket_remove( int bucket ) {
74 --bucket_locklist_count; 74 --bucket_locklist_count;
75} 75}
76 76
77/* Can block */
77ot_vector *mutex_bucket_lock( int bucket ) { 78ot_vector *mutex_bucket_lock( int bucket ) {
78 pthread_mutex_lock( &bucket_mutex ); 79 pthread_mutex_lock( &bucket_mutex );
79 while( bucket_check( bucket ) ) 80 while( bucket_check( bucket ) )
@@ -84,11 +85,7 @@ ot_vector *mutex_bucket_lock( int bucket ) {
84} 85}
85 86
86ot_vector *mutex_bucket_lock_by_hash( ot_hash hash ) { 87ot_vector *mutex_bucket_lock_by_hash( ot_hash hash ) {
87 int bucket = uint32_read_big( (char*)hash ) >> OT_BUCKET_COUNT_SHIFT; 88 return mutex_bucket_lock( uint32_read_big( (char*)hash ) >> OT_BUCKET_COUNT_SHIFT );
88
89 /* Can block */
90 mutex_bucket_lock( bucket );
91 return all_torrents + bucket;
92} 89}
93 90
94void mutex_bucket_unlock( int bucket, int delta_torrentcount ) { 91void mutex_bucket_unlock( int bucket, int delta_torrentcount ) {