mirror of
https://erdgeist.org/gitweb/opentracker
synced 2024-05-10 07:54:50 +00:00
Make mutex_lock_bucket_by_hash generic to any OT_BUCKET_COUNT
This commit is contained in:
@ -13,6 +13,7 @@
|
|||||||
/* Libowfat */
|
/* Libowfat */
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "uint32.h"
|
||||||
|
|
||||||
/* Opentracker */
|
/* Opentracker */
|
||||||
#include "trackerlogic.h"
|
#include "trackerlogic.h"
|
||||||
@ -79,12 +80,10 @@ ot_vector *mutex_bucket_lock( int bucket ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ot_vector *mutex_bucket_lock_by_hash( ot_hash *hash ) {
|
ot_vector *mutex_bucket_lock_by_hash( ot_hash *hash ) {
|
||||||
unsigned char *local_hash = hash[0];
|
int bucket = uint32_read( *hash ) % OT_BUCKET_COUNT;
|
||||||
int bucket = ( local_hash[0] << 2 ) | ( local_hash[1] >> 6 );
|
|
||||||
|
|
||||||
/* Can block */
|
/* Can block */
|
||||||
mutex_bucket_lock( bucket );
|
mutex_bucket_lock( bucket );
|
||||||
|
|
||||||
return all_torrents + bucket;
|
return all_torrents + bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +95,7 @@ void mutex_bucket_unlock( int bucket ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mutex_bucket_unlock_by_hash( ot_hash *hash ) {
|
void mutex_bucket_unlock_by_hash( ot_hash *hash ) {
|
||||||
unsigned char *local_hash = hash[0];
|
mutex_bucket_unlock( uint32_read( *hash ) % OT_BUCKET_COUNT );
|
||||||
int bucket = ( local_hash[0] << 2 ) | ( local_hash[1] >> 6 );
|
|
||||||
mutex_bucket_unlock( bucket );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TaskQueue Magic */
|
/* TaskQueue Magic */
|
||||||
|
Reference in New Issue
Block a user