| 3191 | Mutex NetEventsInterface::g_msgproc_mutex; |
| 3192 | |
| 3193 | void CConnman::ThreadMessageHandler() |
| 3194 | { |
| 3195 | AssertLockNotHeld(m_nodes_mutex); |
| 3196 | |
| 3197 | LOCK(NetEventsInterface::g_msgproc_mutex); |
| 3198 | |
| 3199 | while (!flagInterruptMsgProc) |
| 3200 | { |
| 3201 | bool fMoreWork = false; |
| 3202 | |
| 3203 | { |
| 3204 | // Randomize the order in which we process messages from/to our peers. |
| 3205 | // This prevents attacks in which an attacker exploits having multiple |
| 3206 | // consecutive connections in the m_nodes list. |
| 3207 | const NodesSnapshot snap{*this, /*shuffle=*/true}; |
| 3208 | |
| 3209 | for (CNode* pnode : snap.Nodes()) { |
| 3210 | if (pnode->fDisconnect) |
| 3211 | continue; |
| 3212 | |
| 3213 | // Receive messages |
| 3214 | bool fMoreNodeWork{m_msgproc->ProcessMessages(*pnode, flagInterruptMsgProc)}; |
| 3215 | fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend); |
| 3216 | if (flagInterruptMsgProc) |
| 3217 | return; |
| 3218 | // Send messages |
| 3219 | m_msgproc->SendMessages(*pnode); |
| 3220 | |
| 3221 | if (flagInterruptMsgProc) |
| 3222 | return; |
| 3223 | } |
| 3224 | } |
| 3225 | |
| 3226 | WAIT_LOCK(mutexMsgProc, lock); |
| 3227 | if (!fMoreWork) { |
| 3228 | condMsgProc.wait_until(lock, std::chrono::steady_clock::now() + std::chrono::milliseconds(100), [this]() EXCLUSIVE_LOCKS_REQUIRED(mutexMsgProc) { return fMsgProcWake; }); |
| 3229 | } |
| 3230 | fMsgProcWake = false; |
| 3231 | } |
| 3232 | } |
| 3233 | |
| 3234 | void CConnman::ThreadI2PAcceptIncoming() |
| 3235 | { |
nothing calls this directly
no test coverage detected