Skip to content

Commit fa9c675

Browse files
author
MarcoFalke
committed
Limit scope of all global std::once_flag
1 parent cb88de3 commit fa9c675

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/rpc/server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
static RecursiveMutex cs_rpcWarmup;
2424
static std::atomic<bool> g_rpc_running{false};
25-
static std::once_flag g_rpc_interrupt_flag;
26-
static std::once_flag g_rpc_stop_flag;
2725
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
2826
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
2927
/* Timer-creating functions */
@@ -295,6 +293,7 @@ void StartRPC()
295293

296294
void InterruptRPC()
297295
{
296+
static std::once_flag g_rpc_interrupt_flag;
298297
// This function could be called twice if the GUI has been started with -server=1.
299298
std::call_once(g_rpc_interrupt_flag, []() {
300299
LogPrint(BCLog::RPC, "Interrupting RPC\n");
@@ -305,6 +304,7 @@ void InterruptRPC()
305304

306305
void StopRPC()
307306
{
307+
static std::once_flag g_rpc_stop_flag;
308308
// This function could be called twice if the GUI has been started with -server=1.
309309
assert(!g_rpc_running);
310310
std::call_once(g_rpc_stop_flag, []() {

src/support/lockedpool.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#endif
3030

3131
LockedPoolManager* LockedPoolManager::_instance = nullptr;
32-
std::once_flag LockedPoolManager::init_flag;
3332

3433
/*******************************************************************************/
3534
// Utilities

src/support/lockedpool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ class LockedPoolManager : public LockedPool
221221
/** Return the current instance, or create it once */
222222
static LockedPoolManager& Instance()
223223
{
224-
std::call_once(LockedPoolManager::init_flag, LockedPoolManager::CreateInstance);
224+
static std::once_flag init_flag;
225+
std::call_once(init_flag, LockedPoolManager::CreateInstance);
225226
return *LockedPoolManager::_instance;
226227
}
227228

@@ -234,7 +235,6 @@ class LockedPoolManager : public LockedPool
234235
static bool LockingFailed();
235236

236237
static LockedPoolManager* _instance;
237-
static std::once_flag init_flag;
238238
};
239239

240240
#endif // BITCOIN_SUPPORT_LOCKEDPOOL_H

0 commit comments

Comments
 (0)