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

Method ThreadMessageHandler

src/net.cpp:2320–2359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2318}
2319
2320void CConnman::ThreadMessageHandler()
2321{
2322 SetSyscallSandboxPolicy(SyscallSandboxPolicy::MESSAGE_HANDLER);
2323 while (!flagInterruptMsgProc)
2324 {
2325 bool fMoreWork = false;
2326
2327 {
2328 // Randomize the order in which we process messages from/to our peers.
2329 // This prevents attacks in which an attacker exploits having multiple
2330 // consecutive connections in the m_nodes list.
2331 const NodesSnapshot snap{*this, /*shuffle=*/true};
2332
2333 for (CNode* pnode : snap.Nodes()) {
2334 if (pnode->fDisconnect)
2335 continue;
2336
2337 // Receive messages
2338 bool fMoreNodeWork = m_msgproc->ProcessMessages(pnode, flagInterruptMsgProc);
2339 fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
2340 if (flagInterruptMsgProc)
2341 return;
2342 // Send messages
2343 {
2344 LOCK(pnode->cs_sendProcessing);
2345 m_msgproc->SendMessages(pnode);
2346 }
2347
2348 if (flagInterruptMsgProc)
2349 return;
2350 }
2351 }
2352
2353 WAIT_LOCK(mutexMsgProc, lock);
2354 if (!fMoreWork) {
2355 condMsgProc.wait_until(lock, std::chrono::steady_clock::now() + std::chrono::milliseconds(100), [this]() EXCLUSIVE_LOCKS_REQUIRED(mutexMsgProc) { return fMsgProcWake; });
2356 }
2357 fMsgProcWake = false;
2358 }
2359}
2360
2361void CConnman::ThreadI2PAcceptIncoming()
2362{

Callers

nothing calls this directly

Calls 5

SetSyscallSandboxPolicyFunction · 0.85
ProcessMessagesMethod · 0.80
SendMessagesMethod · 0.80
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.70
wait_untilMethod · 0.45

Tested by

no test coverage detected