aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 50ae0c6252..97be4637a6 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -235,8 +235,11 @@ void Shutdown(InitInterfaces& interfaces)
//
// g_chainstate is referenced here directly (instead of ::ChainstateActive()) because it
// may not have been initialized yet.
- if (g_chainstate && g_chainstate->CanFlushToDisk()) {
- g_chainstate->ForceFlushStateToDisk();
+ {
+ LOCK(cs_main);
+ if (g_chainstate && g_chainstate->CanFlushToDisk()) {
+ g_chainstate->ForceFlushStateToDisk();
+ }
}
// After there are no more peers/RPC left to give us new data which may generate