diff options
Diffstat (limited to 'ot_mutex.c')
-rw-r--r-- | ot_mutex.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -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 */ | ||
77 | ot_vector *mutex_bucket_lock( int bucket ) { | 78 | ot_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 | ||
86 | ot_vector *mutex_bucket_lock_by_hash( ot_hash hash ) { | 87 | ot_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 | ||
94 | void mutex_bucket_unlock( int bucket, int delta_torrentcount ) { | 91 | void mutex_bucket_unlock( int bucket, int delta_torrentcount ) { |