From 33c2465eef2ee2c86cf8f99bad64621b40a5061b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 16 Jan 2015 13:48:49 +1100 Subject: [PATCH] Remove worker instances and their data on killing their client instances --- src/stratifier.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index a7badc22..53f16551 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1115,8 +1115,17 @@ static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, int64_t id, int /* Add a stratum instance to the dead instances list */ static void kill_instance(sdata_t *sdata, stratum_instance_t *client) { - if (client->user_instance) - DL_DELETE(client->user_instance->instances, 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); + free(worker); + } + } LL_PREPEND(sdata->dead_instances, client); sdata->stats.dead++; }