diff --git a/src/stratifier.c b/src/stratifier.c index 9f758fbe..39a2583d 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1260,7 +1260,7 @@ static void drop_client(sdata_t *sdata, int64_t id) ck_wlock(&sdata->instance_lock); client = __instance_by_id(sdata, id); - if (client) { + if (client && likely(!client->ref)) { stratum_instance_t *old_client = NULL; instance = client->user_instance; @@ -1291,6 +1291,8 @@ static void drop_client(sdata_t *sdata, int64_t id) HASH_ITER(hh, sdata->disconnected_instances, client, tmp) { if (now_t - client->disconnected_time < 600) continue; + if (unlikely(client->ref)) + continue; LOGINFO("Ageing disconnected instance %ld to dead", client->id); __del_disconnected(sdata, client); }