|
|
@ -995,14 +995,15 @@ static void __disconnect_session(sdata_t *sdata, const stratum_instance_t *clien |
|
|
|
|
|
|
|
|
|
|
|
/* Removes a client instance we know is on the stratum_instances list and from
|
|
|
|
/* Removes a client instance we know is on the stratum_instances list and from
|
|
|
|
* the user client list if it's been placed on it */ |
|
|
|
* the user client list if it's been placed on it */ |
|
|
|
static void __del_client(sdata_t *sdata, stratum_instance_t *client, user_instance_t *user) |
|
|
|
static void __del_client(sdata_t *sdata, stratum_instance_t *client) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
user_instance_t *user = client->user_instance; |
|
|
|
|
|
|
|
|
|
|
|
HASH_DEL(sdata->stratum_instances, client); |
|
|
|
HASH_DEL(sdata->stratum_instances, client); |
|
|
|
if (user) { |
|
|
|
if (user) { |
|
|
|
DL_DELETE(user->clients, client); |
|
|
|
DL_DELETE(user->clients, client); |
|
|
|
__dec_worker(sdata, user); |
|
|
|
__dec_worker(sdata, user); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void drop_allclients(ckpool_t *ckp) |
|
|
|
static void drop_allclients(ckpool_t *ckp) |
|
|
@ -1017,7 +1018,7 @@ static void drop_allclients(ckpool_t *ckp) |
|
|
|
int64_t client_id = client->id; |
|
|
|
int64_t client_id = client->id; |
|
|
|
|
|
|
|
|
|
|
|
if (!client->ref) { |
|
|
|
if (!client->ref) { |
|
|
|
__del_client(sdata, client, client->user_instance); |
|
|
|
__del_client(sdata, client); |
|
|
|
__kill_instance(sdata, client); |
|
|
|
__kill_instance(sdata, client); |
|
|
|
} else |
|
|
|
} else |
|
|
|
client->dropped = true; |
|
|
|
client->dropped = true; |
|
|
@ -1250,11 +1251,10 @@ static stratum_instance_t *ref_instance_by_id(sdata_t *sdata, const int64_t id) |
|
|
|
return client; |
|
|
|
return client; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_instance_t *user, |
|
|
|
static void __drop_client(sdata_t *sdata, stratum_instance_t *client, bool lazily, char **msg) |
|
|
|
bool lazily, char **msg) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
user_instance_t *user = client->user_instance; |
|
|
|
|
|
|
|
|
|
|
|
__del_client(sdata, client, user); |
|
|
|
|
|
|
|
if (client->workername) { |
|
|
|
if (client->workername) { |
|
|
|
if (user) { |
|
|
|
if (user) { |
|
|
|
ASPRINTF(msg, "Client %"PRId64" %s %suser %s worker %s dropped %s", |
|
|
|
ASPRINTF(msg, "Client %"PRId64" %s %suser %s worker %s dropped %s", |
|
|
@ -1269,6 +1269,7 @@ static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_insta |
|
|
|
ASPRINTF(msg, "Workerless client %"PRId64" %s dropped %s", |
|
|
|
ASPRINTF(msg, "Workerless client %"PRId64" %s dropped %s", |
|
|
|
client->id, client->address, lazily ? "lazily" : ""); |
|
|
|
client->id, client->address, lazily ? "lazily" : ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
__del_client(sdata, client); |
|
|
|
__kill_instance(sdata, client); |
|
|
|
__kill_instance(sdata, client); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1276,7 +1277,6 @@ static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_insta |
|
|
|
static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const char *file, |
|
|
|
static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const char *file, |
|
|
|
const char *func, const int line) |
|
|
|
const char *func, const int line) |
|
|
|
{ |
|
|
|
{ |
|
|
|
user_instance_t *user = client->user_instance; |
|
|
|
|
|
|
|
char_entry_t *entries = NULL; |
|
|
|
char_entry_t *entries = NULL; |
|
|
|
char *msg; |
|
|
|
char *msg; |
|
|
|
int ref; |
|
|
|
int ref; |
|
|
@ -1286,7 +1286,7 @@ static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const |
|
|
|
/* See if there are any instances that were dropped that could not be
|
|
|
|
/* See if there are any instances that were dropped that could not be
|
|
|
|
* moved due to holding a reference and drop them now. */ |
|
|
|
* moved due to holding a reference and drop them now. */ |
|
|
|
if (unlikely(client->dropped && !ref)) { |
|
|
|
if (unlikely(client->dropped && !ref)) { |
|
|
|
__drop_client(sdata, client, user, true, &msg); |
|
|
|
__drop_client(sdata, client, true, &msg); |
|
|
|
add_msg_entry(&entries, &msg); |
|
|
|
add_msg_entry(&entries, &msg); |
|
|
|
} |
|
|
|
} |
|
|
|
ck_wunlock(&sdata->instance_lock); |
|
|
|
ck_wunlock(&sdata->instance_lock); |
|
|
@ -1434,7 +1434,6 @@ static void stratum_add_send(sdata_t *sdata, json_t *val, const int64_t client_i |
|
|
|
static void drop_client(sdata_t *sdata, const int64_t id) |
|
|
|
static void drop_client(sdata_t *sdata, const int64_t id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char_entry_t *entries = NULL; |
|
|
|
char_entry_t *entries = NULL; |
|
|
|
user_instance_t *user = NULL; |
|
|
|
|
|
|
|
stratum_instance_t *client; |
|
|
|
stratum_instance_t *client; |
|
|
|
char *msg; |
|
|
|
char *msg; |
|
|
|
|
|
|
|
|
|
|
@ -1444,11 +1443,10 @@ static void drop_client(sdata_t *sdata, const int64_t id) |
|
|
|
client = __instance_by_id(sdata, id); |
|
|
|
client = __instance_by_id(sdata, id); |
|
|
|
if (client && !client->dropped) { |
|
|
|
if (client && !client->dropped) { |
|
|
|
__disconnect_session(sdata, client); |
|
|
|
__disconnect_session(sdata, client); |
|
|
|
user = client->user_instance; |
|
|
|
|
|
|
|
/* If the client is still holding a reference, don't drop them
|
|
|
|
/* If the client is still holding a reference, don't drop them
|
|
|
|
* now but wait till the reference is dropped */ |
|
|
|
* now but wait till the reference is dropped */ |
|
|
|
if (!client->ref) { |
|
|
|
if (!client->ref) { |
|
|
|
__drop_client(sdata, client, user, false, &msg); |
|
|
|
__drop_client(sdata, client, false, &msg); |
|
|
|
add_msg_entry(&entries, &msg); |
|
|
|
add_msg_entry(&entries, &msg); |
|
|
|
} else |
|
|
|
} else |
|
|
|
client->dropped = true; |
|
|
|
client->dropped = true; |
|
|
|