From 72e27635942231e8557e1823e73c482096be841b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 27 Dec 2016 10:19:19 +1100 Subject: [PATCH] Use a common start ping mechanism between threads. --- src/connector.c | 7 +++++-- src/generator.c | 12 +++++++----- src/stratifier.c | 11 +++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/connector.c b/src/connector.c index 95019419..7fc0a93f 100644 --- a/src/connector.c +++ b/src/connector.c @@ -676,9 +676,12 @@ static void *receiver(void *arg) } /* Wait for the stratifier to be ready for us */ - do { + while (42) { buf = send_recv_proc(ckp->stratifier, "ping"); - } while (!buf); + if (buf) + break; + cksleep_ms(10); + }; free(buf); while (42) { diff --git a/src/generator.c b/src/generator.c index b32e8af8..4eb12bbe 100644 --- a/src/generator.c +++ b/src/generator.c @@ -3101,14 +3101,16 @@ void *generator(void *arg) gdata->ckp = ckp; if (ckp->proxy) { - char *buf = NULL; + char *buf; /* Wait for the stratifier to be ready for us */ - do { - cksleep_ms(10); + while (42) { buf = send_recv_proc(ckp->stratifier, "ping"); - } while (!buf); - dealloc(buf); + if (buf) + break; + 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 5b57275c..869f19fc 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -8021,9 +8021,9 @@ void *stratifier(void *arg) pthread_t pth_blockupdate, pth_statsupdate, pth_heartbeat; ckpool_t *ckp = pi->ckp; int64_t randomiser; - char *buf = NULL; sdata_t *sdata; int threads; + char *buf; rename_proc(pi->processname); LOGWARNING("%s stratifier starting", ckp->name); @@ -8033,12 +8033,15 @@ void *stratifier(void *arg) sdata->verbose = true; /* Wait for the generator to have something for us */ - do { + while (42) { if (ckp->proxy) break; buf = send_recv_proc(ckp->generator, "ping"); - } while (!buf); - dealloc(buf); + if (buf) + break; + cksleep_ms(10); + }; + free(buf); if (!ckp->proxy) { if (!generator_checkaddr(ckp, ckp->btcaddress)) {