From f11250dd2d31d2d4537e0d54bb07df768ac86f7a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 21 Jan 2015 14:15:29 +1100 Subject: [PATCH] Do not move clients from hash/linked lists while they hold a ref count --- src/stratifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }