mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-17 19:10:40 +01:00
scripted-diff: rename CSemaphoreGrant and CSemaphore for net
-BEGIN VERIFY SCRIPT- sed -i -e 's|CSemaphoreGrant|SemaphoreGrant|g' -e 's|CSemaphore|Semaphore|g' src/net.h src/net.cpp -END VERIFY SCRIPT-
This commit is contained in:
16
src/net.cpp
16
src/net.cpp
@@ -1893,7 +1893,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
|
||||
if (max_connections != std::nullopt && existing_connections >= max_connections) return false;
|
||||
|
||||
// Max total outbound connections already exist
|
||||
CSemaphoreGrant grant(*semOutbound, true);
|
||||
SemaphoreGrant grant(*semOutbound, true);
|
||||
if (!grant) return false;
|
||||
|
||||
OpenNetworkConnection(CAddress(), false, std::move(grant), address.c_str(), conn_type, /*use_v2transport=*/use_v2transport);
|
||||
@@ -2409,7 +2409,7 @@ void CConnman::ProcessAddrFetch()
|
||||
// peer doesn't support it or immediately disconnects us for another reason.
|
||||
const bool use_v2transport(GetLocalServices() & NODE_P2P_V2);
|
||||
CAddress addr;
|
||||
CSemaphoreGrant grant(*semOutbound, /*fTry=*/true);
|
||||
SemaphoreGrant grant(*semOutbound, /*fTry=*/true);
|
||||
if (grant) {
|
||||
OpenNetworkConnection(addr, false, std::move(grant), strDest.c_str(), ConnectionType::ADDR_FETCH, use_v2transport);
|
||||
}
|
||||
@@ -2583,7 +2583,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std
|
||||
|
||||
PerformReconnections();
|
||||
|
||||
CSemaphoreGrant grant(*semOutbound);
|
||||
SemaphoreGrant grant(*semOutbound);
|
||||
if (interruptNet)
|
||||
return;
|
||||
|
||||
@@ -2961,7 +2961,7 @@ void CConnman::ThreadOpenAddedConnections()
|
||||
AssertLockNotHeld(m_reconnections_mutex);
|
||||
while (true)
|
||||
{
|
||||
CSemaphoreGrant grant(*semAddnode);
|
||||
SemaphoreGrant grant(*semAddnode);
|
||||
std::vector<AddedNodeInfo> vInfo = GetAddedNodeInfo(/*include_connected=*/false);
|
||||
bool tried = false;
|
||||
for (const AddedNodeInfo& info : vInfo) {
|
||||
@@ -2974,7 +2974,7 @@ void CConnman::ThreadOpenAddedConnections()
|
||||
CAddress addr(CService(), NODE_NONE);
|
||||
OpenNetworkConnection(addr, false, std::move(grant), info.m_params.m_added_node.c_str(), ConnectionType::MANUAL, info.m_params.m_use_v2transport);
|
||||
if (!interruptNet.sleep_for(std::chrono::milliseconds(500))) return;
|
||||
grant = CSemaphoreGrant(*semAddnode, /*fTry=*/true);
|
||||
grant = SemaphoreGrant(*semAddnode, /*fTry=*/true);
|
||||
}
|
||||
// See if any reconnections are desired.
|
||||
PerformReconnections();
|
||||
@@ -2985,7 +2985,7 @@ void CConnman::ThreadOpenAddedConnections()
|
||||
}
|
||||
|
||||
// if successful, this moves the passed grant to the constructed node
|
||||
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant&& grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport)
|
||||
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, SemaphoreGrant&& grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport)
|
||||
{
|
||||
AssertLockNotHeld(m_unused_i2p_sessions_mutex);
|
||||
assert(conn_type != ConnectionType::INBOUND);
|
||||
@@ -3336,11 +3336,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
||||
|
||||
if (semOutbound == nullptr) {
|
||||
// initialize semaphore
|
||||
semOutbound = std::make_unique<CSemaphore>(std::min(m_max_automatic_outbound, m_max_automatic_connections));
|
||||
semOutbound = std::make_unique<Semaphore>(std::min(m_max_automatic_outbound, m_max_automatic_connections));
|
||||
}
|
||||
if (semAddnode == nullptr) {
|
||||
// initialize semaphore
|
||||
semAddnode = std::make_unique<CSemaphore>(m_max_addnode);
|
||||
semAddnode = std::make_unique<Semaphore>(m_max_addnode);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
10
src/net.h
10
src/net.h
@@ -729,7 +729,7 @@ public:
|
||||
// Setting fDisconnect to true will cause the node to be disconnected the
|
||||
// next time DisconnectNodes() runs
|
||||
std::atomic_bool fDisconnect{false};
|
||||
CSemaphoreGrant grantOutbound;
|
||||
SemaphoreGrant grantOutbound;
|
||||
std::atomic<int> nRefCount{0};
|
||||
|
||||
const uint64_t nKeyedNetGroup;
|
||||
@@ -1136,7 +1136,7 @@ public:
|
||||
bool GetNetworkActive() const { return fNetworkActive; };
|
||||
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
|
||||
void SetNetworkActive(bool active);
|
||||
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant&& grant_outbound, const char* strDest, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
||||
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, SemaphoreGrant&& grant_outbound, const char* strDest, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
||||
bool CheckIncomingNonce(uint64_t nonce);
|
||||
void ASMapHealthCheck();
|
||||
|
||||
@@ -1491,8 +1491,8 @@ private:
|
||||
*/
|
||||
std::atomic<ServiceFlags> m_local_services;
|
||||
|
||||
std::unique_ptr<CSemaphore> semOutbound;
|
||||
std::unique_ptr<CSemaphore> semAddnode;
|
||||
std::unique_ptr<Semaphore> semOutbound;
|
||||
std::unique_ptr<Semaphore> semAddnode;
|
||||
|
||||
/**
|
||||
* Maximum number of automatic connections permitted, excluding manual
|
||||
@@ -1614,7 +1614,7 @@ private:
|
||||
struct ReconnectionInfo
|
||||
{
|
||||
CAddress addr_connect;
|
||||
CSemaphoreGrant grant;
|
||||
SemaphoreGrant grant;
|
||||
std::string destination;
|
||||
ConnectionType conn_type;
|
||||
bool use_v2transport;
|
||||
|
||||
Reference in New Issue
Block a user