Browse Source

Get rid of cute locking in disconnected session check for simplicity

master
Con Kolivas 10 years ago
parent
commit
9df5a9cf2e
  1. 7
      src/stratifier.c

7
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 */ /* Number is in BE but we don't swap either of them */
hex2bin(&session64, sessionid, 8); hex2bin(&session64, sessionid, 8);
ck_ilock(&sdata->instance_lock); ck_wlock(&sdata->instance_lock);
HASH_ITER(hh, sdata->stratum_instances, instance, tmp) { HASH_ITER(hh, sdata->stratum_instances, instance, tmp) {
if (instance->id == id) if (instance->id == id)
continue; continue;
@ -1140,15 +1140,12 @@ static bool disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid,
if (instance) { if (instance) {
/* If we've found a matching disconnected instance, use it only /* If we've found a matching disconnected instance, use it only
* once and discard it */ * once and discard it */
ck_ulock(&sdata->instance_lock);
HASH_DEL(sdata->disconnected_instances, instance); HASH_DEL(sdata->disconnected_instances, instance);
kill_instance(sdata, instance); kill_instance(sdata, instance);
ck_dwilock(&sdata->instance_lock);
ret = true; ret = true;
} }
out_unlock: out_unlock:
ck_uilock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);
out: out:
return ret; return ret;
} }

Loading…
Cancel
Save