diff options
| author | erdgeist <> | 2009-02-10 14:49:11 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-02-10 14:49:11 +0000 |
| commit | f1ce4ea4994aa1488b51b6004546aafede72ed74 (patch) | |
| tree | 8dc8b5b34ef9c481d5ff1571f10e50a6724c9967 /ot_mutex.c | |
| parent | 957981ac73929d5aa720ba9bb3363ce0da411f14 (diff) | |
unify lock and unlock code style
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 ) { |
