From ca0f0ea7225c4194202fe8699aec5be6c51e4b48 Mon Sep 17 00:00:00 2001 From: Marco Nilsson Date: Wed, 24 Jan 2018 09:23:09 +0100 Subject: [PATCH] Wait for retired tally to finish before switching to the new. Right on block 1144120 there is a risk of two tallies running concurrently, both writing to the same variables. This will cause a crash, for example when syncing. --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 04f137997f..b321dfea8c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -255,7 +255,7 @@ bool bForceUpdate = false; bool bGlobalcomInitialized = false; bool bStakeMinerOutOfSyncWithNetwork = false; volatile bool bDoTally_retired = false; -volatile bool bTallyFinished_retired = false; +volatile bool bTallyFinished_retired = true; bool bGridcoinGUILoaded = false; extern double LederstrumpfMagnitude2(double Magnitude, int64_t locktime); @@ -4264,6 +4264,15 @@ void GridcoinServices() // Tally research averages. if ((nBestHeight % TALLY_GRANULARITY) == 0) { + // Wait for previous retired tally to finish if running. + // This can happen when syncing the chain. + if(!bTallyFinished_retired) + { + printf("SVC: Wait for retired tally to finish\n"); + while(!bTallyFinished_retired) + MilliSleep(10); + } + if (fDebug) printf("SVC: TallyNetworkAverages (v9 %%%d) height %d\n",TALLY_GRANULARITY,nBestHeight); TallyNetworkAverages_v9(); }