kanoi 10 years ago
parent
commit
5d28fc6935
  1. 11
      src/generator.c
  2. 9
      src/stratifier.c

11
src/generator.c

@ -209,6 +209,7 @@ static int gen_loop(proc_instance_t *pi)
{ {
int sockd = -1, ret = 0, selret; int sockd = -1, ret = 0, selret;
server_instance_t *si = NULL; server_instance_t *si = NULL;
bool reconnecting = false;
unixsock_t *us = &pi->us; unixsock_t *us = &pi->us;
ckpool_t *ckp = pi->ckp; ckpool_t *ckp = pi->ckp;
bool started = false; bool started = false;
@ -218,14 +219,20 @@ static int gen_loop(proc_instance_t *pi)
char hash[68]; char hash[68];
reconnect: reconnect:
if (si) if (si) {
kill_server(si); kill_server(si);
reconnecting = true;
}
si = live_server(ckp); si = live_server(ckp);
if (!si) if (!si)
goto out; goto out;
gbt = si->data; gbt = si->data;
cs = &si->cs; cs = &si->cs;
if (reconnecting) {
LOGWARNING("Failed over to bitcoind: %s:%s", cs->url, cs->port);
reconnecting = false;
}
retry: retry:
do { do {
@ -238,7 +245,7 @@ retry:
} while (selret < 1); } while (selret < 1);
if (unlikely(cs->fd < 0)) { if (unlikely(cs->fd < 0)) {
LOGWARNING("Bitcoind socket invalidated, will atempt failover"); LOGWARNING("Bitcoind socket invalidated, will attempt failover");
goto reconnect; goto reconnect;
} }

9
src/stratifier.c

@ -1254,11 +1254,12 @@ static json_t *parse_subscribe(int64_t client_id, json_t *params_val)
* user or creates a new one. */ * user or creates a new one. */
static user_instance_t *authorise_user(const char *workername) static user_instance_t *authorise_user(const char *workername)
{ {
char *username = strdupa(workername); char *base_username = strdupa(workername), *username;
user_instance_t *instance; user_instance_t *instance;
username = strsep(&username, "."); username = strsep(&base_username, "._");
username = strsep(&username, "_"); if (!username || !strlen(username))
username = base_username;
if (strlen(username) > 127) if (strlen(username) > 127)
username[127] = '\0'; username[127] = '\0';
@ -1392,7 +1393,7 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
*err_val = json_string("Empty workername parameter"); *err_val = json_string("Empty workername parameter");
goto out; goto out;
} }
if (!memcmp(buf, ".", 1)) { if (!memcmp(buf, ".", 1) || !memcmp(buf, "_", 1)) {
*err_val = json_string("Empty username parameter"); *err_val = json_string("Empty username parameter");
goto out; goto out;
} }

Loading…
Cancel
Save