Browse Source

Count the number of workernames and use that as the upper limit for the sanity check in statsupdate

master
ckolivas 10 years ago
parent
commit
24cb6e0c3e
  1. 9
      src/stratifier.c

9
src/stratifier.c

@ -171,6 +171,7 @@ struct user_instance {
/* A linked list of all connected workers of this user */ /* A linked list of all connected workers of this user */
worker_instance_t *worker_instances; worker_instance_t *worker_instances;
int workernames; /* How many different workernames exist */
int workers; int workers;
@ -1905,6 +1906,7 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client,
read_workerstats(ckp, worker); read_workerstats(ckp, worker);
worker->start_time = time(NULL); worker->start_time = time(NULL);
client->worker_instance = worker; client->worker_instance = worker;
instance->workernames++;
} }
DL_APPEND(instance->instances, client); DL_APPEND(instance->instances, client);
ck_wunlock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);
@ -3513,11 +3515,10 @@ static void *statsupdate(void *arg)
/* Decay times per worker */ /* Decay times per worker */
DL_FOREACH(instance->worker_instances, worker) { DL_FOREACH(instance->worker_instances, worker) {
/* FIXME: This shouldn't happen and is purely a sanity /* Sanity check, should never happen */
* breakout till the real issue is found and fixed. */ if (unlikely(iterations++ > instance->workernames)) {
if (unlikely(iterations++ > instance->workers)) {
LOGWARNING("Statsupdate trying to iterate more than %d existing workers for worker %s", LOGWARNING("Statsupdate trying to iterate more than %d existing workers for worker %s",
instance->workers, worker->workername); instance->workernames, worker->workername);
break; break;
} }
per_tdiff = tvdiff(&now, &worker->last_share); per_tdiff = tvdiff(&now, &worker->last_share);

Loading…
Cancel
Save