Browse Source

kill_instance always follows del_disconnected

master
ckolivas 10 years ago
parent
commit
b172162f27
  1. 35
      src/stratifier.c

35
src/stratifier.c

@ -857,10 +857,27 @@ static void update_base(ckpool_t *ckp, int prio)
create_pthread(pth, do_update, ur); 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) static void __del_disconnected(sdata_t *sdata, stratum_instance_t *client)
{ {
HASH_DEL(sdata->disconnected_instances, client); HASH_DEL(sdata->disconnected_instances, client);
sdata->stats.disconnected--; sdata->stats.disconnected--;
__kill_instance(sdata, client);
} }
static void drop_allclients(ckpool_t *ckp) 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; 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 */ /* 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) 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 /* If we've found a matching disconnected instance, use it only
* once and discard it */ * once and discard it */
__del_disconnected(sdata, instance); __del_disconnected(sdata, instance);
__kill_instance(sdata, instance);
ret = true; ret = true;
} }
out_unlock: out_unlock:
@ -1290,7 +1290,6 @@ static void drop_client(sdata_t *sdata, int64_t id)
continue; continue;
LOGINFO("Discarding aged disconnected instance %ld", client->id); LOGINFO("Discarding aged disconnected instance %ld", client->id);
__del_disconnected(sdata, client); __del_disconnected(sdata, client);
__kill_instance(sdata, client);
} }
/* Discard any dead instances that no longer hold any reference counts, /* Discard any dead instances that no longer hold any reference counts,
* freeing up their memory safely */ * freeing up their memory safely */

Loading…
Cancel
Save