Skip to content

Commit 1a9ef1d

Browse files
committed
refactor: Replace RecursiveMutex with Mutex in Shutdown()
1 parent 0fc6ea2 commit 1a9ef1d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/init.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <compat/sanity.h>
1919
#include <consensus/validation.h>
2020
#include <fs.h>
21+
#include <hash.h>
2122
#include <httprpc.h>
2223
#include <httpserver.h>
2324
#include <index/blockfilterindex.h>
@@ -42,6 +43,7 @@
4243
#include <script/sigcache.h>
4344
#include <script/standard.h>
4445
#include <shutdown.h>
46+
#include <sync.h>
4547
#include <timedata.h>
4648
#include <torcontrol.h>
4749
#include <txdb.h>
@@ -53,8 +55,6 @@
5355
#include <util/threadnames.h>
5456
#include <util/translation.h>
5557
#include <validation.h>
56-
#include <hash.h>
57-
5858

5959
#include <validationinterface.h>
6060
#include <walletinitinterface.h>
@@ -171,11 +171,10 @@ void Interrupt(NodeContext& node)
171171

172172
void Shutdown(NodeContext& node)
173173
{
174+
static Mutex g_shutdown_mutex;
175+
TRY_LOCK(g_shutdown_mutex, lock_shutdown);
176+
if (!lock_shutdown) return;
174177
LogPrintf("%s: In progress...\n", __func__);
175-
static RecursiveMutex cs_Shutdown;
176-
TRY_LOCK(cs_Shutdown, lockShutdown);
177-
if (!lockShutdown)
178-
return;
179178

180179
/// Note: Shutdown() must be able to handle cases in which initialization failed part of the way,
181180
/// for example if the data directory was found to be locked.

0 commit comments

Comments
 (0)