From 96f055486c9fcfe1c20618f045dbda3d4960c813 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 18 Dec 2015 08:05:17 +1100 Subject: [PATCH] We should serialise calls to GBT, not just update_base --- src/stratifier.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index fef6eb13..26e931ab 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -921,6 +921,8 @@ static void *do_update(void *arg) pthread_detach(pthread_self()); rename_proc("updater"); + /* Serialise access to getbase to avoid out of order new block notifies */ + cksem_wait(&sdata->update_sem); retry: buf = send_recv_generator(ckp, "getbase", prio); if (unlikely(!buf)) { @@ -976,8 +978,6 @@ retry: json_decref(val); generate_coinbase(ckp, wb); - /* Serialise access to add_base to avoid out of order new block notifies */ - cksem_wait(&sdata->update_sem); add_base(ckp, wb, &new_block); /* Reset the update time to avoid stacked low priority notifies. Bring * forward the next notify in case of a new block. */ @@ -985,12 +985,13 @@ retry: if (new_block) now_t -= ckp->update_interval / 2; sdata->update_time = now_t; - cksem_post(&sdata->update_sem); stratum_broadcast_update(sdata, new_block); ret = true; LOGINFO("Broadcast updated stratum base"); out: + cksem_post(&sdata->update_sem); + /* Send a ping to miners if we fail to get a base to keep them * connected while bitcoind recovers(?) */ if (unlikely(!ret)) {