From 24cb6e0c3e7b0011c7b3ea5be149c88c9ba1d0c2 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sat, 17 Jan 2015 23:20:02 +1100 Subject: [PATCH] Count the number of workernames and use that as the upper limit for the sanity check in statsupdate --- src/stratifier.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 99dac9e9..0f8fbd0d 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -171,6 +171,7 @@ struct user_instance { /* A linked list of all connected workers of this user */ worker_instance_t *worker_instances; + int workernames; /* How many different workernames exist */ int workers; @@ -1905,6 +1906,7 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client, read_workerstats(ckp, worker); worker->start_time = time(NULL); client->worker_instance = worker; + instance->workernames++; } DL_APPEND(instance->instances, client); ck_wunlock(&sdata->instance_lock); @@ -3513,11 +3515,10 @@ static void *statsupdate(void *arg) /* Decay times per worker */ DL_FOREACH(instance->worker_instances, worker) { - /* FIXME: This shouldn't happen and is purely a sanity - * breakout till the real issue is found and fixed. */ - if (unlikely(iterations++ > instance->workers)) { + /* Sanity check, should never happen */ + if (unlikely(iterations++ > instance->workernames)) { LOGWARNING("Statsupdate trying to iterate more than %d existing workers for worker %s", - instance->workers, worker->workername); + instance->workernames, worker->workername); break; } per_tdiff = tvdiff(&now, &worker->last_share);