|
|
@ -1094,11 +1094,21 @@ static void parse_remote_submitblock(ckpool_t *ckp, const json_t *val, const cha |
|
|
|
send_proc(ckp->generator, gbt_block); |
|
|
|
send_proc(ckp->generator, gbt_block); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void ping_upstream(cdata_t *cdata) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ASPRINTF(&buf, "{\"method\":\"ping\"}\n"); |
|
|
|
|
|
|
|
ckmsgq_add(cdata->upstream_sends, buf); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void *urecv_process(void *arg) |
|
|
|
static void *urecv_process(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckpool_t *ckp = (ckpool_t *)arg; |
|
|
|
ckpool_t *ckp = (ckpool_t *)arg; |
|
|
|
cdata_t *cdata = ckp->data; |
|
|
|
cdata_t *cdata = ckp->data; |
|
|
|
connsock_t *cs = &cdata->upstream_cs; |
|
|
|
connsock_t *cs = &cdata->upstream_cs; |
|
|
|
|
|
|
|
bool alive = true; |
|
|
|
|
|
|
|
|
|
|
|
ckp->proxy = true; |
|
|
|
ckp->proxy = true; |
|
|
|
|
|
|
|
|
|
|
|
rename_proc("ureceiver"); |
|
|
|
rename_proc("ureceiver"); |
|
|
@ -1114,12 +1124,16 @@ static void *urecv_process(void *arg) |
|
|
|
cksem_wait(&cs->sem); |
|
|
|
cksem_wait(&cs->sem); |
|
|
|
ret = read_socket_line(cs, &timeout); |
|
|
|
ret = read_socket_line(cs, &timeout); |
|
|
|
if (ret < 1) { |
|
|
|
if (ret < 1) { |
|
|
|
if (likely(!ret)) |
|
|
|
ping_upstream(cdata); |
|
|
|
|
|
|
|
if (likely(!ret)) { |
|
|
|
LOGDEBUG("No message from upstream pool"); |
|
|
|
LOGDEBUG("No message from upstream pool"); |
|
|
|
else |
|
|
|
} else { |
|
|
|
LOGNOTICE("Failed to read from upstream pool"); |
|
|
|
LOGNOTICE("Failed to read from upstream pool"); |
|
|
|
|
|
|
|
alive = false; |
|
|
|
|
|
|
|
} |
|
|
|
goto nomsg; |
|
|
|
goto nomsg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
alive = true; |
|
|
|
val = json_loads(cs->buf, 0, NULL); |
|
|
|
val = json_loads(cs->buf, 0, NULL); |
|
|
|
if (unlikely(!val)) { |
|
|
|
if (unlikely(!val)) { |
|
|
|
LOGWARNING("Received non-json msg from upstream pool %s", |
|
|
|
LOGWARNING("Received non-json msg from upstream pool %s", |
|
|
@ -1135,10 +1149,15 @@ static void *urecv_process(void *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
if (!safecmp(method, "submitblock")) |
|
|
|
if (!safecmp(method, "submitblock")) |
|
|
|
parse_remote_submitblock(ckp, val, cs->buf); |
|
|
|
parse_remote_submitblock(ckp, val, cs->buf); |
|
|
|
|
|
|
|
else if (!safecmp(method, "pong")) |
|
|
|
|
|
|
|
LOGDEBUG("Received upstream pong"); |
|
|
|
else |
|
|
|
else |
|
|
|
LOGWARNING("Unrecognised upstream method %s", method); |
|
|
|
LOGWARNING("Unrecognised upstream method %s", method); |
|
|
|
nomsg: |
|
|
|
nomsg: |
|
|
|
cksem_post(&cs->sem); |
|
|
|
cksem_post(&cs->sem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!alive) |
|
|
|
|
|
|
|
sleep(5); |
|
|
|
} |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|