Skip to content

Commit 9ad6f14

Browse files
author
MarcoFalke
committed
Merge #19220: refactor: Replace RecursiveMutex with Mutex in warnings.cpp
bacbfb6 refactor: Replace RecursiveMutex with Mutex in warnings.cpp (Hennadii Stepanov) Pull request description: The functions that could lock this mutex, i.e., `SetMiscWarning()`, `{S,G}etfLargeWorkForkFound()`, `SetfLargeWorkInvalidChainFound()`, `GetWarnings()`, do not call itself recursively, and do not call each other either directly or indirectly. Therefore, the `g_warnings_mutex` could be a non-recursive mutex. Related to #19180. ACKs for top commit: laanwj: Code review ACK bacbfb6 MarcoFalke: ACK bacbfb6 , reviewed with -W --word-diff-regex=. 🎿 Tree-SHA512: cc06d3d30e4051115d176dcfbd496c8562a70087369bccde756c1de42d7dc3f415ef20d3d69ad2599c1d0cd4228d604d7564adc17beac7b6ff92b924b8c20d54
2 parents a79bca2 + bacbfb6 commit 9ad6f14

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/warnings.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
#include <util/system.h>
1010
#include <util/translation.h>
1111

12-
static RecursiveMutex cs_warnings;
13-
static std::string strMiscWarning GUARDED_BY(cs_warnings);
14-
static bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false;
15-
static bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false;
12+
static Mutex g_warnings_mutex;
13+
static std::string strMiscWarning GUARDED_BY(g_warnings_mutex);
14+
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
15+
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
1616

1717
void SetMiscWarning(const std::string& strWarning)
1818
{
19-
LOCK(cs_warnings);
19+
LOCK(g_warnings_mutex);
2020
strMiscWarning = strWarning;
2121
}
2222

2323
void SetfLargeWorkForkFound(bool flag)
2424
{
25-
LOCK(cs_warnings);
25+
LOCK(g_warnings_mutex);
2626
fLargeWorkForkFound = flag;
2727
}
2828

2929
bool GetfLargeWorkForkFound()
3030
{
31-
LOCK(cs_warnings);
31+
LOCK(g_warnings_mutex);
3232
return fLargeWorkForkFound;
3333
}
3434

3535
void SetfLargeWorkInvalidChainFound(bool flag)
3636
{
37-
LOCK(cs_warnings);
37+
LOCK(g_warnings_mutex);
3838
fLargeWorkInvalidChainFound = flag;
3939
}
4040

@@ -44,7 +44,7 @@ std::string GetWarnings(bool verbose)
4444
std::string warnings_verbose;
4545
const std::string warning_separator = "<hr />";
4646

47-
LOCK(cs_warnings);
47+
LOCK(g_warnings_mutex);
4848

4949
// Pre-release build warning
5050
if (!CLIENT_VERSION_IS_RELEASE) {

0 commit comments

Comments
 (0)