@@ -1893,7 +1893,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
1893
1893
if (max_connections != std::nullopt && existing_connections >= max_connections) return false ;
1894
1894
1895
1895
// Max total outbound connections already exist
1896
- SemaphoreGrant grant (*semOutbound, true );
1896
+ CountingSemaphoreGrant<> grant (*semOutbound, true );
1897
1897
if (!grant) return false ;
1898
1898
1899
1899
OpenNetworkConnection (CAddress (), false , std::move (grant), address.c_str (), conn_type, /* use_v2transport=*/ use_v2transport);
@@ -2409,7 +2409,7 @@ void CConnman::ProcessAddrFetch()
2409
2409
// peer doesn't support it or immediately disconnects us for another reason.
2410
2410
const bool use_v2transport (GetLocalServices () & NODE_P2P_V2);
2411
2411
CAddress addr;
2412
- SemaphoreGrant grant (*semOutbound, /* fTry=*/ true );
2412
+ CountingSemaphoreGrant<> grant (*semOutbound, /* fTry=*/ true );
2413
2413
if (grant) {
2414
2414
OpenNetworkConnection (addr, false , std::move (grant), strDest.c_str (), ConnectionType::ADDR_FETCH, use_v2transport);
2415
2415
}
@@ -2583,7 +2583,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std
2583
2583
2584
2584
PerformReconnections ();
2585
2585
2586
- SemaphoreGrant grant (*semOutbound);
2586
+ CountingSemaphoreGrant<> grant (*semOutbound);
2587
2587
if (interruptNet)
2588
2588
return ;
2589
2589
@@ -2961,7 +2961,7 @@ void CConnman::ThreadOpenAddedConnections()
2961
2961
AssertLockNotHeld (m_reconnections_mutex);
2962
2962
while (true )
2963
2963
{
2964
- SemaphoreGrant grant (*semAddnode);
2964
+ CountingSemaphoreGrant<> grant (*semAddnode);
2965
2965
std::vector<AddedNodeInfo> vInfo = GetAddedNodeInfo (/* include_connected=*/ false );
2966
2966
bool tried = false ;
2967
2967
for (const AddedNodeInfo& info : vInfo) {
@@ -2974,7 +2974,7 @@ void CConnman::ThreadOpenAddedConnections()
2974
2974
CAddress addr (CService (), NODE_NONE);
2975
2975
OpenNetworkConnection (addr, false , std::move (grant), info.m_params .m_added_node .c_str (), ConnectionType::MANUAL, info.m_params .m_use_v2transport );
2976
2976
if (!interruptNet.sleep_for (std::chrono::milliseconds (500 ))) return ;
2977
- grant = SemaphoreGrant (*semAddnode, /* fTry=*/ true );
2977
+ grant = CountingSemaphoreGrant<> (*semAddnode, /* fTry=*/ true );
2978
2978
}
2979
2979
// See if any reconnections are desired.
2980
2980
PerformReconnections ();
@@ -2985,7 +2985,7 @@ void CConnman::ThreadOpenAddedConnections()
2985
2985
}
2986
2986
2987
2987
// if successful, this moves the passed grant to the constructed node
2988
- void CConnman::OpenNetworkConnection (const CAddress& addrConnect, bool fCountFailure , SemaphoreGrant && grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport)
2988
+ void CConnman::OpenNetworkConnection (const CAddress& addrConnect, bool fCountFailure , CountingSemaphoreGrant<> && grant_outbound, const char *pszDest, ConnectionType conn_type, bool use_v2transport)
2989
2989
{
2990
2990
AssertLockNotHeld (m_unused_i2p_sessions_mutex);
2991
2991
assert (conn_type != ConnectionType::INBOUND);
@@ -3336,11 +3336,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
3336
3336
3337
3337
if (semOutbound == nullptr ) {
3338
3338
// initialize semaphore
3339
- semOutbound = std::make_unique<Semaphore >(std::min (m_max_automatic_outbound, m_max_automatic_connections));
3339
+ semOutbound = std::make_unique<std::counting_semaphore<> >(std::min (m_max_automatic_outbound, m_max_automatic_connections));
3340
3340
}
3341
3341
if (semAddnode == nullptr ) {
3342
3342
// initialize semaphore
3343
- semAddnode = std::make_unique<Semaphore >(m_max_addnode);
3343
+ semAddnode = std::make_unique<std::counting_semaphore<> >(m_max_addnode);
3344
3344
}
3345
3345
3346
3346
//
0 commit comments