diff --git a/src/connector.c b/src/connector.c index 7fc0a93f..c29a5505 100644 --- a/src/connector.c +++ b/src/connector.c @@ -653,7 +653,6 @@ static void *receiver(void *arg) ckpool_t *ckp = cdata->ckp; uint64_t serverfds, i; int ret, epfd; - char *buf; rename_proc("creceiver"); @@ -676,13 +675,8 @@ static void *receiver(void *arg) } /* Wait for the stratifier to be ready for us */ - while (42) { - buf = send_recv_proc(ckp->stratifier, "ping"); - if (buf) - break; + while (!ckp->stratifier_ready) cksleep_ms(10); - }; - free(buf); while (42) { uint64_t edu64; @@ -1362,7 +1356,6 @@ static void connector_loop(proc_instance_t *pi, cdata_t *cdata) int ret = 0; char *buf; - LOGWARNING("%s connector ready", ckp->name); last_stats = cdata->start_time; retry: @@ -1608,6 +1601,9 @@ void *connector(void *arg) create_pthread(&cdata->pth_receiver, receiver, cdata); cdata->start_time = time(NULL); + ckp->connector_ready = true; + LOGWARNING("%s connector ready", ckp->name); + connector_loop(pi, cdata); out: /* We should never get here unless there's a fatal error */ diff --git a/src/generator.c b/src/generator.c index 82e33d4b..a9a534db 100644 --- a/src/generator.c +++ b/src/generator.c @@ -3126,16 +3126,9 @@ void *generator(void *arg) gdata->ckp = ckp; if (ckp->proxy) { - char *buf; - /* Wait for the stratifier to be ready for us */ - while (42) { - buf = send_recv_proc(ckp->stratifier, "ping"); - if (buf) - break; + while (!ckp->stratifier_ready) cksleep_ms(10); - }; - free(buf); proxy_mode(ckp, pi); } else server_mode(ckp, pi); diff --git a/src/stratifier.c b/src/stratifier.c index a68c304b..fa99b46c 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -8034,7 +8034,6 @@ void *stratifier(void *arg) int64_t randomiser; sdata_t *sdata; int threads; - char *buf; rename_proc(pi->processname); LOGWARNING("%s stratifier starting", ckp->name); @@ -8044,15 +8043,8 @@ void *stratifier(void *arg) sdata->verbose = true; /* Wait for the generator to have something for us */ - while (42) { - if (ckp->proxy) - break; - buf = send_recv_proc(ckp->generator, "ping"); - if (buf) - break; + while (!ckp->proxy && !ckp->generator_ready) cksleep_ms(10); - }; - free(buf); if (!ckp->proxy) { if (!generator_checkaddr(ckp, ckp->btcaddress)) { @@ -8124,6 +8116,7 @@ void *stratifier(void *arg) mutex_init(&sdata->share_lock); mutex_init(&sdata->block_lock); + ckp->stratifier_ready = true; LOGWARNING("%s stratifier ready", ckp->name); stratum_loop(ckp, pi);