MCPcopy Create free account
hub / github.com/ElementsProject/elements / ThreadOpenAddedConnections

Method ThreadOpenAddedConnections

src/net.cpp:2256–2282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2254}
2255
2256void CConnman::ThreadOpenAddedConnections()
2257{
2258 SetSyscallSandboxPolicy(SyscallSandboxPolicy::NET_ADD_CONNECTION);
2259 while (true)
2260 {
2261 CSemaphoreGrant grant(*semAddnode);
2262 std::vector<AddedNodeInfo> vInfo = GetAddedNodeInfo();
2263 bool tried = false;
2264 for (const AddedNodeInfo& info : vInfo) {
2265 if (!info.fConnected) {
2266 if (!grant.TryAcquire()) {
2267 // If we've used up our semaphore and need a new one, let's not wait here since while we are waiting
2268 // the addednodeinfo state might change.
2269 break;
2270 }
2271 tried = true;
2272 CAddress addr(CService(), NODE_NONE);
2273 OpenNetworkConnection(addr, false, &grant, info.strAddedNode.c_str(), ConnectionType::MANUAL);
2274 if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
2275 return;
2276 }
2277 }
2278 // Retry every 60 seconds if a connection was attempted, otherwise two seconds
2279 if (!interruptNet.sleep_for(std::chrono::seconds(tried ? 60 : 2)))
2280 return;
2281 }
2282}
2283
2284// if successful, this moves the passed grant to the constructed node
2285void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, ConnectionType conn_type)

Callers

nothing calls this directly

Calls 4

SetSyscallSandboxPolicyFunction · 0.85
TryAcquireMethod · 0.80
sleep_forMethod · 0.80
CServiceClass · 0.70

Tested by

no test coverage detected