Browse Source

Add subproxy information to generator messages where appropriate

master
Con Kolivas 10 years ago
parent
commit
a98d510f9f
  1. 63
      src/generator.c

63
src/generator.c

@ -575,8 +575,8 @@ static bool parse_subscribe(connsock_t *cs, proxy_instance_t *proxi)
retry: retry:
parsed = true; parsed = true;
if (!(buf = new_proxy_line(cs))) { if (!(buf = new_proxy_line(cs))) {
LOGNOTICE("Proxy %d:%s failed to receive line in parse_subscribe", LOGNOTICE("Proxy %d:%d %s failed to receive line in parse_subscribe",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
goto out; goto out;
} }
LOGDEBUG("parse_subscribe received %s", buf); LOGDEBUG("parse_subscribe received %s", buf);
@ -608,8 +608,8 @@ retry:
buf = NULL; buf = NULL;
goto retry; goto retry;
} }
LOGNOTICE("Proxy %d:%s failed to parse subscribe response in parse_subscribe", LOGNOTICE("Proxy %d:%d %s failed to parse subscribe response in parse_subscribe",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
goto out; goto out;
} }
@ -704,8 +704,8 @@ retry:
ret = send_json_msg(cs, req); ret = send_json_msg(cs, req);
json_decref(req); json_decref(req);
if (!ret) { if (!ret) {
LOGNOTICE("Proxy %d:%s failed to send message in subscribe_stratum", LOGNOTICE("Proxy %d:%d %s failed to send message in subscribe_stratum",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
goto out; goto out;
} }
ret = parse_subscribe(cs, proxi); ret = parse_subscribe(cs, proxi);
@ -713,24 +713,24 @@ retry:
goto out; goto out;
if (proxi->no_params) { if (proxi->no_params) {
LOGNOTICE("Proxy %d:%s failed all subscription options in subscribe_stratum", LOGNOTICE("Proxy %d:%d %s failed all subscription options in subscribe_stratum",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
goto out; goto out;
} }
if (proxi->sessionid) { if (proxi->sessionid) {
LOGINFO("Proxy %d:%s failed sessionid reconnect in subscribe_stratum, retrying without", LOGINFO("Proxy %d:%d %s failed sessionid reconnect in subscribe_stratum, retrying without",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
proxi->no_sessionid = true; proxi->no_sessionid = true;
dealloc(proxi->sessionid); dealloc(proxi->sessionid);
} else { } else {
LOGINFO("Proxy %d:%s failed connecting with parameters in subscribe_stratum, retrying without", LOGINFO("Proxy %d:%d %s failed connecting with parameters in subscribe_stratum, retrying without",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
proxi->no_params = true; proxi->no_params = true;
} }
ret = connect_proxy(cs); ret = connect_proxy(cs);
if (!ret) { if (!ret) {
LOGNOTICE("Proxy %d:%s failed to reconnect in subscribe_stratum", LOGNOTICE("Proxy %d:%d %s failed to reconnect in subscribe_stratum",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
goto out; goto out;
} }
goto retry; goto retry;
@ -1189,8 +1189,8 @@ static bool auth_stratum(ckpool_t *ckp, connsock_t *cs, proxy_instance_t *proxi)
ret = send_json_msg(cs, req); ret = send_json_msg(cs, req);
json_decref(req); json_decref(req);
if (!ret) { if (!ret) {
LOGNOTICE("Proxy %d:%s failed to send message in auth_stratum", LOGNOTICE("Proxy %d:%d %s failed to send message in auth_stratum",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
Close(cs->fd); Close(cs->fd);
goto out; goto out;
} }
@ -1201,8 +1201,8 @@ static bool auth_stratum(ckpool_t *ckp, connsock_t *cs, proxy_instance_t *proxi)
free(buf); free(buf);
buf = next_proxy_line(cs, proxi); buf = next_proxy_line(cs, proxi);
if (!buf) { if (!buf) {
LOGNOTICE("Proxy %d:%s failed to receive line in auth_stratum", LOGNOTICE("Proxy %d:%d %s failed to receive line in auth_stratum",
proxi->id, proxi->si->url); proxi->id, proxi->subid, proxi->si->url);
ret = false; ret = false;
goto out; goto out;
} }
@ -1211,28 +1211,28 @@ static bool auth_stratum(ckpool_t *ckp, connsock_t *cs, proxy_instance_t *proxi)
val = json_msg_result(buf, &res_val, &err_val); val = json_msg_result(buf, &res_val, &err_val);
if (!val) { if (!val) {
LOGWARNING("Proxy %d:%s failed to get a json result in auth_stratum, got: %s", LOGWARNING("Proxy %d:%d %s failed to get a json result in auth_stratum, got: %s",
proxi->id, proxi->si->url, buf); proxi->id, proxi->subid, proxi->si->url, buf);
goto out; goto out;
} }
if (err_val && !json_is_null(err_val)) { if (err_val && !json_is_null(err_val)) {
LOGWARNING("Proxy %d:%s failed to authorise in auth_stratum due to err_val, got: %s", LOGWARNING("Proxy %d:%d %s failed to authorise in auth_stratum due to err_val, got: %s",
proxi->id, proxi->si->url, buf); proxi->id, proxi->subid, proxi->si->url, buf);
goto out; goto out;
} }
if (res_val) { if (res_val) {
ret = json_is_true(res_val); ret = json_is_true(res_val);
if (!ret) { if (!ret) {
LOGWARNING("Proxy %d:%s failed to authorise in auth_stratum, got: %s", LOGWARNING("Proxy %d:%d %s failed to authorise in auth_stratum, got: %s",
proxi->id, proxi->si->url, buf); proxi->id, proxi->subid, proxi->si->url, buf);
goto out; goto out;
} }
} else { } else {
/* No result and no error but successful val means auth success */ /* No result and no error but successful val means auth success */
ret = true; ret = true;
} }
LOGINFO("Proxy %d:%s auth success in auth_stratum", proxi->id, proxi->si->url); LOGINFO("Proxy %d:%d %s auth success in auth_stratum", proxi->id, proxi->subid, proxi->si->url);
out: out:
if (val) if (val)
json_decref(val); json_decref(val);
@ -1327,8 +1327,8 @@ static void submit_share(gdata_t *gdata, json_t *val)
return json_decref(val); return json_decref(val);
} }
if (!proxi->alive) { if (!proxi->alive) {
LOGNOTICE("Client %"PRId64" attempting to send shares to dead proxy %d, dropping", LOGNOTICE("Client %"PRId64" attempting to send shares to dead proxy %d:%d, dropping",
client_id, id); client_id, id, subid);
stratifier_drop_client(ckp, client_id); stratifier_drop_client(ckp, client_id);
return json_decref(val); return json_decref(val);
} }
@ -1468,17 +1468,20 @@ static void *proxy_send(void *arg)
"method", "mining.submit"); "method", "mining.submit");
ret = send_json_msg(cs, val); ret = send_json_msg(cs, val);
json_decref(val); json_decref(val);
} else { } else if (!jobid) {
LOGNOTICE("Proxy %d:%s failed to find matching jobid in proxysend", LOGNOTICE("Proxy %d:%s failed to find matching jobid in proxysend",
proxy->id, proxy->si->url); proxy->id, proxy->si->url);
} else {
LOGNOTICE("Failed to find subproxy %d:%d to send message to",
proxy->id, subid);
} }
free(jobid); free(jobid);
json_decref(msg->json_msg); json_decref(msg->json_msg);
free(msg); free(msg);
if (!ret && subproxy) { if (!ret && subproxy) {
if (cs->fd > 0) { if (cs->fd > 0) {
LOGWARNING("Proxy %d:%s failed to send msg in proxy_send, dropping to reconnect", LOGWARNING("Proxy %d:%d %s failed to send msg in proxy_send, dropping to reconnect",
proxy->id, proxy->si->url); proxy->id, proxy->subid, proxy->si->url);
Close(cs->fd); Close(cs->fd);
} }
if (!parent_proxy(subproxy) && !subproxy->disabled) if (!parent_proxy(subproxy) && !subproxy->disabled)

Loading…
Cancel
Save