aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-06-08 07:00:59 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-06-08 07:01:14 -0400
commit8496dbeba6878d4a123995170a0ad8d125c17695 (patch)
tree9105703abd10920b033ae845e0b75904be50b62c /src
parent399a0d9dc7a15bd4a9184ba19e1f251cfbb450c8 (diff)
parent78c8f4fe11706cf5c165777c2ca122bd933b8b6a (diff)
downloadbitcoin-8496dbeba6878d4a123995170a0ad8d125c17695.tar.xz
Merge #19190: refactor: Replace RecursiveMutex with Mutex in netbase.cpp
78c8f4fe11706cf5c165777c2ca122bd933b8b6a 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 78c8f4fe11706cf5c165777c2ca122bd933b8b6a , reviewed with the -W git option 👮 vasild: ACK 78c8f4fe verified that recursion does not happen Tree-SHA512: fc077fb371f38af5d05f1383c6bebf9926167c257892936fefd2d4fe6f679ca40124d25099e09f645d8ec266df222f96c5d0f9fd39eddcad15cbde0b427bc205
Diffstat (limited to 'src')
-rw-r--r--src/netbase.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index a70179cb16..9fe03c6a24 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -28,9 +28,9 @@
#endif
// Settings
-static RecursiveMutex cs_proxyInfos;
-static proxyType proxyInfo[NET_MAX] GUARDED_BY(cs_proxyInfos);
-static proxyType nameProxy GUARDED_BY(cs_proxyInfos);
+static Mutex g_proxyinfo_mutex;
+static proxyType proxyInfo[NET_MAX] GUARDED_BY(g_proxyinfo_mutex);
+static proxyType nameProxy GUARDED_BY(g_proxyinfo_mutex);
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
bool fNameLookup = DEFAULT_NAME_LOOKUP;
@@ -711,14 +711,14 @@ bool SetProxy(enum Network net, const proxyType &addrProxy) {
assert(net >= 0 && net < NET_MAX);
if (!addrProxy.IsValid())
return false;
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
proxyInfo[net] = addrProxy;
return true;
}
bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
assert(net >= 0 && net < NET_MAX);
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
if (!proxyInfo[net].IsValid())
return false;
proxyInfoOut = proxyInfo[net];
@@ -744,13 +744,13 @@ bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
bool SetNameProxy(const proxyType &addrProxy) {
if (!addrProxy.IsValid())
return false;
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
nameProxy = addrProxy;
return true;
}
bool GetNameProxy(proxyType &nameProxyOut) {
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
if(!nameProxy.IsValid())
return false;
nameProxyOut = nameProxy;
@@ -758,12 +758,12 @@ bool GetNameProxy(proxyType &nameProxyOut) {
}
bool HaveNameProxy() {
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
return nameProxy.IsValid();
}
bool IsProxy(const CNetAddr &addr) {
- LOCK(cs_proxyInfos);
+ LOCK(g_proxyinfo_mutex);
for (int i = 0; i < NET_MAX; i++) {
if (addr == static_cast<CNetAddr>(proxyInfo[i].proxy))
return true;