summaryrefslogtreecommitdiff
path: root/ot_mutex.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2009-02-10 14:49:11 +0000
committerDirk Engling <erdgeist@erdgeist.org>2009-02-10 14:49:11 +0000
commitc958c53d402f5cbe19c6d88b420725260a8bf029 (patch)
treeac8bc23a07e1c10be15f464c20dbb446ec98e2c4 /ot_mutex.c
parent3f592359608e6da25fc38a5197ca9971d3e28309 (diff)
downloadopentracker-c958c53d402f5cbe19c6d88b420725260a8bf029.tar.gz
opentracker-c958c53d402f5cbe19c6d88b420725260a8bf029.zip
unify lock and unlock code style
Diffstat (limited to 'ot_mutex.c')
-rw-r--r--ot_mutex.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 5dd5b14..6a8e25a 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -74,6 +74,7 @@ static void bucket_remove( int bucket ) {
--bucket_locklist_count;
}
+/* Can block */
ot_vector *mutex_bucket_lock( int bucket ) {
pthread_mutex_lock( &bucket_mutex );
while( bucket_check( bucket ) )
@@ -84,11 +85,7 @@ ot_vector *mutex_bucket_lock( int bucket ) {
}
ot_vector *mutex_bucket_lock_by_hash( ot_hash hash ) {
- int bucket = uint32_read_big( (char*)hash ) >> OT_BUCKET_COUNT_SHIFT;
-
- /* Can block */
- mutex_bucket_lock( bucket );
- return all_torrents + bucket;
+ return mutex_bucket_lock( uint32_read_big( (char*)hash ) >> OT_BUCKET_COUNT_SHIFT );
}
void mutex_bucket_unlock( int bucket, int delta_torrentcount ) {
@@ -333,4 +330,4 @@ void mutex_deinit( ) {
byte_zero( all_torrents, sizeof( all_torrents ) );
}
-const char *g_version_mutex_c = "$Source: /home/cvsroot/opentracker/ot_mutex.c,v $: $Revision: 1.20 $\n";
+const char *g_version_mutex_c = "$Source: /home/cvsroot/opentracker/ot_mutex.c,v $: $Revision: 1.21 $\n";