|
|
@ -1216,6 +1216,8 @@ static void dec_worker(ckpool_t *ckp, user_instance_t *instance) |
|
|
|
static void drop_client(sdata_t *sdata, int64_t id) |
|
|
|
static void drop_client(sdata_t *sdata, int64_t id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
|
|
|
|
user_instance_t *instance = NULL; |
|
|
|
|
|
|
|
ckpool_t *ckp = NULL; |
|
|
|
bool dec = false; |
|
|
|
bool dec = false; |
|
|
|
|
|
|
|
|
|
|
|
LOGINFO("Stratifier dropping client %ld", id); |
|
|
|
LOGINFO("Stratifier dropping client %ld", id); |
|
|
@ -1225,10 +1227,11 @@ static void drop_client(sdata_t *sdata, int64_t id) |
|
|
|
if (client) { |
|
|
|
if (client) { |
|
|
|
stratum_instance_t *old_client = NULL; |
|
|
|
stratum_instance_t *old_client = NULL; |
|
|
|
|
|
|
|
|
|
|
|
__inc_instance_ref(client); |
|
|
|
|
|
|
|
if (client->authorised) { |
|
|
|
if (client->authorised) { |
|
|
|
dec = true; |
|
|
|
dec = true; |
|
|
|
client->authorised = false; |
|
|
|
client->authorised = false; |
|
|
|
|
|
|
|
ckp = client->ckp; |
|
|
|
|
|
|
|
instance = client->user_instance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HASH_DEL(sdata->stratum_instances, client); |
|
|
|
HASH_DEL(sdata->stratum_instances, client); |
|
|
@ -1242,18 +1245,8 @@ static void drop_client(sdata_t *sdata, int64_t id) |
|
|
|
LL_PREPEND(sdata->dead_instances, client); |
|
|
|
LL_PREPEND(sdata->dead_instances, client); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ck_wunlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Decrease worker count outside of instance_lock to avoid recursive
|
|
|
|
|
|
|
|
* locking */ |
|
|
|
|
|
|
|
if (dec) |
|
|
|
|
|
|
|
dec_worker(client->ckp, client->user_instance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Cull old unused clients lazily when there are no more reference
|
|
|
|
/* Cull old unused clients lazily when there are no more reference
|
|
|
|
* counts for them. */ |
|
|
|
* counts for them. */ |
|
|
|
ck_wlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
if (client) |
|
|
|
|
|
|
|
__dec_instance_ref(client); |
|
|
|
|
|
|
|
LL_FOREACH_SAFE(sdata->dead_instances, client, tmp) { |
|
|
|
LL_FOREACH_SAFE(sdata->dead_instances, client, tmp) { |
|
|
|
if (!client->ref) { |
|
|
|
if (!client->ref) { |
|
|
|
LOGINFO("Stratifier discarding instance %ld", client->id); |
|
|
|
LOGINFO("Stratifier discarding instance %ld", client->id); |
|
|
@ -1264,6 +1257,11 @@ static void drop_client(sdata_t *sdata, int64_t id) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ck_wunlock(&sdata->instance_lock); |
|
|
|
ck_wunlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Decrease worker count outside of instance_lock to avoid recursive
|
|
|
|
|
|
|
|
* locking */ |
|
|
|
|
|
|
|
if (dec) |
|
|
|
|
|
|
|
dec_worker(ckp, instance); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void stratum_broadcast_message(sdata_t *sdata, const char *msg) |
|
|
|
static void stratum_broadcast_message(sdata_t *sdata, const char *msg) |
|
|
|