Browse Source

Allow reconnect to take a :url,port extension to specify where to reconnect to

master
ckolivas 10 years ago
parent
commit
cab3e94ada
  1. 2
      src/ckpool.c
  2. 15
      src/stratifier.c

2
src/ckpool.c

@ -296,7 +296,7 @@ retry:
send_unix_msg(sockd, "rejecting");
} else if (cmdmatch(buf, "reconnect")) {
LOGWARNING("Listener received request to send reconnect to clients");
send_procmsg(ckp->stratifier, "reconnect");
send_procmsg(ckp->stratifier, buf);
send_unix_msg(sockd, "reconnecting");
} else if (cmdmatch(buf, "restart")) {
LOGWARNING("Listener received restart message, attempting handover");

15
src/stratifier.c

@ -1145,10 +1145,21 @@ static void stratum_broadcast_message(const char *msg)
/* Send a generic reconnect to all clients without parameters to make them
* reconnect to the same server. */
static void reconnect_clients(void)
static void reconnect_clients(const char *cmd)
{
char *port = strdupa(cmd), *url = NULL;
json_t *json_msg;
strsep(&port, ":");
if (port)
url = strsep(&port, ",");
if (url && port) {
int port_no;
port_no = strtol(port, NULL, 10);
JSON_CPACK(json_msg, "{sosss[sii]}", "id", json_null(), "method", "client.reconnect",
"params", url, port_no, 0);
} else
JSON_CPACK(json_msg, "{sosss[]}", "id", json_null(), "method", "client.reconnect",
"params");
stratum_broadcast(json_msg);
@ -1347,7 +1358,7 @@ retry:
} else if (cmdmatch(buf, "noblock")) {
block_reject(buf + 8);
} else if (cmdmatch(buf, "reconnect")) {
reconnect_clients();
reconnect_clients(buf);
} else if (cmdmatch(buf, "loglevel")) {
sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else {

Loading…
Cancel
Save