From 9df5a9cf2ec934617dc3e06bd3038ac4002bd162 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 16 Jan 2015 12:06:15 +1100 Subject: [PATCH] Get rid of cute locking in disconnected session check for simplicity --- src/stratifier.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 6ea66790..42b73038 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1126,7 +1126,7 @@ static bool disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, /* Number is in BE but we don't swap either of them */ hex2bin(&session64, sessionid, 8); - ck_ilock(&sdata->instance_lock); + ck_wlock(&sdata->instance_lock); HASH_ITER(hh, sdata->stratum_instances, instance, tmp) { if (instance->id == id) continue; @@ -1140,15 +1140,12 @@ static bool disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, if (instance) { /* If we've found a matching disconnected instance, use it only * once and discard it */ - ck_ulock(&sdata->instance_lock); HASH_DEL(sdata->disconnected_instances, instance); kill_instance(sdata, instance); - ck_dwilock(&sdata->instance_lock); - ret = true; } out_unlock: - ck_uilock(&sdata->instance_lock); + ck_wunlock(&sdata->instance_lock); out: return ret; }