Browse Source

Reconnect all clients of a certain user when adding a userproxy in userproxy mode

master
Con Kolivas 9 years ago
parent
commit
1c5b8ae516
  1. 10
      src/generator.c
  2. 26
      src/stratifier.c

10
src/generator.c

@ -1400,6 +1400,14 @@ static void stratifier_reconnect_client(ckpool_t *ckp, const int64_t id)
send_proc(ckp->stratifier, buf); 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 */ /* 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) static int add_share(gdata_t *gdata, const int64_t client_id, const double diff)
{ {
@ -1809,6 +1817,8 @@ out:
Close(cs->fd); Close(cs->fd);
} }
proxi->alive = ret; proxi->alive = ret;
if (ckp->userproxy && ret && !proxi->global)
stratifier_reconnect_user(ckp, proxi->userid);
return ret; return ret;
} }

26
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); 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 */ /* API commands */
static user_instance_t *get_user(sdata_t *sdata, const char *username); static user_instance_t *get_user(sdata_t *sdata, const char *username);
@ -3261,9 +3277,17 @@ retry:
ret = sscanf(buf, "reconnclient=%"PRId64, &client_id); ret = sscanf(buf, "reconnclient=%"PRId64, &client_id);
if (ret < 0) if (ret < 0)
LOGDEBUG("Stratifier failed to parse reconnclient command: %s", buf); LOGWARNING("Stratifier failed to parse reconnclient command: %s", buf);
else else
reconnect_client_id(sdata, client_id); 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")) { } else if (cmdmatch(buf, "dropall")) {
drop_allclients(ckp); drop_allclients(ckp);
} else if (cmdmatch(buf, "block")) { } else if (cmdmatch(buf, "block")) {

Loading…
Cancel
Save