Skip to content

Commit 8496dbe

Browse files
author
MarcoFalke
committed
Merge #19190: refactor: Replace RecursiveMutex with Mutex in netbase.cpp
78c8f4f refactor: Replace RecursiveMutex with Mutex in netbase.cpp (Hennadii Stepanov) Pull request description: The functions that could lock this mutex, i.e., `{S,G}etProxy()`, `{S,G}etNameProxy()`, `HaveNameProxy()`, `IsProxy()`, do not call itself recursively, and do not call each other either directly or indirectly. Therefore, the `g_proxyinfo_mutex` could be a non-recursive mutex. Related to #19180. ACKs for top commit: MarcoFalke: ACK 78c8f4f , reviewed with the -W git option 👮 vasild: ACK 78c8f4f verified that recursion does not happen Tree-SHA512: fc077fb371f38af5d05f1383c6bebf9926167c257892936fefd2d4fe6f679ca40124d25099e09f645d8ec266df222f96c5d0f9fd39eddcad15cbde0b427bc205
2 parents 399a0d9 + 78c8f4f commit 8496dbe

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/netbase.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#endif
2929

3030
// Settings
31-
static RecursiveMutex cs_proxyInfos;
32-
static proxyType proxyInfo[NET_MAX] GUARDED_BY(cs_proxyInfos);
33-
static proxyType nameProxy GUARDED_BY(cs_proxyInfos);
31+
static Mutex g_proxyinfo_mutex;
32+
static proxyType proxyInfo[NET_MAX] GUARDED_BY(g_proxyinfo_mutex);
33+
static proxyType nameProxy GUARDED_BY(g_proxyinfo_mutex);
3434
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
3535
bool fNameLookup = DEFAULT_NAME_LOOKUP;
3636

@@ -711,14 +711,14 @@ bool SetProxy(enum Network net, const proxyType &addrProxy) {
711711
assert(net >= 0 && net < NET_MAX);
712712
if (!addrProxy.IsValid())
713713
return false;
714-
LOCK(cs_proxyInfos);
714+
LOCK(g_proxyinfo_mutex);
715715
proxyInfo[net] = addrProxy;
716716
return true;
717717
}
718718

719719
bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
720720
assert(net >= 0 && net < NET_MAX);
721-
LOCK(cs_proxyInfos);
721+
LOCK(g_proxyinfo_mutex);
722722
if (!proxyInfo[net].IsValid())
723723
return false;
724724
proxyInfoOut = proxyInfo[net];
@@ -744,26 +744,26 @@ bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
744744
bool SetNameProxy(const proxyType &addrProxy) {
745745
if (!addrProxy.IsValid())
746746
return false;
747-
LOCK(cs_proxyInfos);
747+
LOCK(g_proxyinfo_mutex);
748748
nameProxy = addrProxy;
749749
return true;
750750
}
751751

752752
bool GetNameProxy(proxyType &nameProxyOut) {
753-
LOCK(cs_proxyInfos);
753+
LOCK(g_proxyinfo_mutex);
754754
if(!nameProxy.IsValid())
755755
return false;
756756
nameProxyOut = nameProxy;
757757
return true;
758758
}
759759

760760
bool HaveNameProxy() {
761-
LOCK(cs_proxyInfos);
761+
LOCK(g_proxyinfo_mutex);
762762
return nameProxy.IsValid();
763763
}
764764

765765
bool IsProxy(const CNetAddr &addr) {
766-
LOCK(cs_proxyInfos);
766+
LOCK(g_proxyinfo_mutex);
767767
for (int i = 0; i < NET_MAX; i++) {
768768
if (addr == static_cast<CNetAddr>(proxyInfo[i].proxy))
769769
return true;

0 commit comments

Comments
 (0)