diff --git a/src/generator.c b/src/generator.c index f0053df0..36a1e7f1 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1400,6 +1400,14 @@ static void stratifier_reconnect_client(ckpool_t *ckp, const int64_t id) send_proc(ckp->stratifier, buf); } +static void stratifier_reconnect_user(ckpool_t *ckp, const int userid) +{ + char buf[256]; + + sprintf(buf, "reconnuser=%d", userid); + send_proc(ckp->stratifier, buf); +} + /* Add a share to the gdata share hashlist. Returns the share id */ static int add_share(gdata_t *gdata, const int64_t client_id, const double diff) { @@ -1809,6 +1817,8 @@ out: Close(cs->fd); } proxi->alive = ret; + if (ckp->userproxy && ret && !proxi->global) + stratifier_reconnect_user(ckp, proxi->userid); return ret; } diff --git a/src/stratifier.c b/src/stratifier.c index 6979d3b8..e49d5b60 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2611,6 +2611,22 @@ static void reconnect_client_id(sdata_t *sdata, const int64_t client_id) dec_instance_ref(sdata, client); } +/* Reconnect all clients with a particular userid */ +static void reconnect_user_id(sdata_t *sdata, int userid) +{ + stratum_instance_t *client, *tmp; + + LOGWARNING("Dropping user id %d", userid); + + ck_rlock(&sdata->instance_lock); + HASH_ITER(hh, sdata->stratum_instances, client, tmp) { + if (client->user_id != userid) + continue; + reconnect_client(sdata, client); + } + ck_runlock(&sdata->instance_lock); +} + /* API commands */ static user_instance_t *get_user(sdata_t *sdata, const char *username); @@ -3261,9 +3277,17 @@ retry: ret = sscanf(buf, "reconnclient=%"PRId64, &client_id); if (ret < 0) - LOGDEBUG("Stratifier failed to parse reconnclient command: %s", buf); + LOGWARNING("Stratifier failed to parse reconnclient command: %s", buf); else reconnect_client_id(sdata, client_id); + } else if (cmdmatch(buf, "reconnuser")) { + int userid; + + ret = sscanf(buf, "reconnuser=%d", &userid); + if (ret < 0) + LOGWARNING("Stratifier failed to parse reconnuser command: %s", buf); + else + reconnect_user_id(sdata, userid); } else if (cmdmatch(buf, "dropall")) { drop_allclients(ckp); } else if (cmdmatch(buf, "block")) {