| 2270 | Mutex NetEventsInterface::g_msgproc_mutex; |
| 2271 | |
| 2272 | void CConnman::ThreadMessageHandler() { |
| 2273 | LOCK(NetEventsInterface::g_msgproc_mutex); |
| 2274 | |
| 2275 | while (!flagInterruptMsgProc) { |
| 2276 | bool fMoreWork = false; |
| 2277 | |
| 2278 | { |
| 2279 | // Randomize the order in which we process messages from/to our |
| 2280 | // peers. This prevents attacks in which an attacker exploits having |
| 2281 | // multiple consecutive connections in the vNodes list. |
| 2282 | const NodesSnapshot snap{*this, /*shuffle=*/true}; |
| 2283 | |
| 2284 | for (CNode *pnode : snap.Nodes()) { |
| 2285 | if (pnode->fDisconnect) { |
| 2286 | continue; |
| 2287 | } |
| 2288 | |
| 2289 | bool fMoreNodeWork = false; |
| 2290 | // Receive messages |
| 2291 | for (auto interface : m_msgproc) { |
| 2292 | fMoreNodeWork |= interface->ProcessMessages( |
| 2293 | *config, pnode, flagInterruptMsgProc); |
| 2294 | } |
| 2295 | fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend); |
| 2296 | if (flagInterruptMsgProc) { |
| 2297 | return; |
| 2298 | } |
| 2299 | |
| 2300 | // Send messages |
| 2301 | for (auto interface : m_msgproc) { |
| 2302 | interface->SendMessages(*config, pnode); |
| 2303 | } |
| 2304 | |
| 2305 | if (flagInterruptMsgProc) { |
| 2306 | return; |
| 2307 | } |
| 2308 | } |
| 2309 | } |
| 2310 | |
| 2311 | WAIT_LOCK(mutexMsgProc, lock); |
| 2312 | if (!fMoreWork) { |
| 2313 | condMsgProc.wait_until(lock, |
| 2314 | std::chrono::steady_clock::now() + |
| 2315 | std::chrono::milliseconds(100), |
| 2316 | [this]() EXCLUSIVE_LOCKS_REQUIRED( |
| 2317 | mutexMsgProc) { return fMsgProcWake; }); |
| 2318 | } |
| 2319 | fMsgProcWake = false; |
| 2320 | } |
| 2321 | } |
| 2322 | |
| 2323 | void CConnman::ThreadI2PAcceptIncoming() { |
| 2324 | static constexpr auto err_wait_begin = 1s; |
nothing calls this directly
no test coverage detected