From b172162f276e5993ce974b1032e6567c48bee7fa Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sat, 17 Jan 2015 17:07:34 +1100 Subject: [PATCH] kill_instance always follows del_disconnected --- src/stratifier.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index c04aa3f3..d45fedce 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -857,10 +857,27 @@ static void update_base(ckpool_t *ckp, int prio) create_pthread(pth, do_update, ur); } +/* Add a stratum instance to the dead instances list */ +static void __kill_instance(sdata_t *sdata, stratum_instance_t *client) +{ + user_instance_t *instance = client->user_instance; + + if (instance) { + worker_instance_t *worker = client->worker_instance; + + DL_DELETE(instance->instances, client); + if (worker) + DL_DELETE(instance->worker_instances, worker); + } + LL_PREPEND(sdata->dead_instances, client); + sdata->stats.dead++; +} + static void __del_disconnected(sdata_t *sdata, stratum_instance_t *client) { HASH_DEL(sdata->disconnected_instances, client); sdata->stats.disconnected--; + __kill_instance(sdata, client); } static void drop_allclients(ckpool_t *ckp) @@ -1112,22 +1129,6 @@ static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, int64_t id, int return instance; } -/* Add a stratum instance to the dead instances list */ -static void __kill_instance(sdata_t *sdata, stratum_instance_t *client) -{ - user_instance_t *instance = client->user_instance; - - if (instance) { - worker_instance_t *worker = client->worker_instance; - - DL_DELETE(instance->instances, client); - if (worker) - DL_DELETE(instance->worker_instances, worker); - } - LL_PREPEND(sdata->dead_instances, client); - sdata->stats.dead++; -} - /* Only supports a full ckpool instance sessionid with an 8 byte sessionid */ static bool disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, int64_t id) { @@ -1157,7 +1158,6 @@ static bool disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, /* If we've found a matching disconnected instance, use it only * once and discard it */ __del_disconnected(sdata, instance); - __kill_instance(sdata, instance); ret = true; } out_unlock: @@ -1290,7 +1290,6 @@ static void drop_client(sdata_t *sdata, int64_t id) continue; LOGINFO("Discarding aged disconnected instance %ld", client->id); __del_disconnected(sdata, client); - __kill_instance(sdata, client); } /* Discard any dead instances that no longer hold any reference counts, * freeing up their memory safely */