From c7794a3d80dbc52972cc1281fe5a52acc8afa406 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 15 Dec 2015 12:27:42 +1100 Subject: [PATCH] Retry getbase after a failure up to 5 times or indefinitely if a block change has been identified --- src/stratifier.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index cabc654c..37a0cda7 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -908,10 +908,10 @@ static void broadcast_ping(sdata_t *sdata); static void *do_update(void *arg) { struct update_req *ur = (struct update_req *)arg; + int prio = ur->prio, retries = 0; ckpool_t *ckp = ur->ckp; sdata_t *sdata = ckp->data; bool new_block = false; - int prio = ur->prio; bool ret = false; workbase_t *wb; time_t now_t; @@ -921,15 +921,20 @@ static void *do_update(void *arg) pthread_detach(pthread_self()); rename_proc("updater"); +retry: buf = send_recv_generator(ckp, "getbase", prio); if (unlikely(!buf)) { LOGNOTICE("Get base in update_base delayed due to higher priority request"); goto out; } if (unlikely(cmdmatch(buf, "failed"))) { - LOGWARNING("Generator returned failure in update_base"); - goto out; + if (retries++ < 5 || prio == GEN_PRIORITY) { + LOGWARNING("Generator returned failure in update_base, retry #%d", retries); + goto retry; + } } + if (unlikely(retries)) + LOGWARNING("Generator succeeded in update_base after retrying"); wb = ckzalloc(sizeof(workbase_t)); wb->ckp = ckp;