| 2318 | } |
| 2319 | |
| 2320 | void 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 | |
| 2361 | void CConnman::ThreadI2PAcceptIncoming() |
| 2362 | { |
nothing calls this directly
no test coverage detected