From 7c905ba729f78b71a77be198a5c9680ce3644367 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 19 Apr 2021 03:25:18 +0200 Subject: De-bottleneck mutex access code --- ot_mutex.c | 76 +++++++++----------------------------------------------------- 1 file changed, 10 insertions(+), 66 deletions(-) diff --git a/ot_mutex.c b/ot_mutex.c index 772d936..9d87d0f 100644 --- a/ot_mutex.c +++ b/ot_mutex.c @@ -25,65 +25,14 @@ /* Our global all torrents list */ static ot_vector all_torrents[OT_BUCKET_COUNT]; +static pthread_mutex_t bucket_mutex[OT_BUCKET_COUNT]; static size_t g_torrent_count; -/* Bucket Magic */ -static int bucket_locklist[ OT_MAX_THREADS ]; -static int bucket_locklist_count = 0; -static pthread_mutex_t bucket_mutex; -static pthread_cond_t bucket_being_unlocked; - /* Self pipe from opentracker.c */ extern int g_self_pipe[2]; -static int bucket_check( int bucket ) { - /* C should come with auto-i ;) */ - int i; - - /* No more space to acquire lock to bucket -- should not happen */ - if( bucket_locklist_count == OT_MAX_THREADS ) { - fprintf( stderr, "More lock requests than mutexes. Consult source code.\n" ); - return -1; - } - - /* See, if bucket is already locked */ - for( i=0; i