refactor: re-order conditions over flags for m_edge_trig_events - follow-up for bitcoin#21563

This commit is contained in:
Konstantin Akimov 2024-10-08 17:44:00 +07:00
parent 6ed62b323c
commit c52a582a3f
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 7 additions and 6 deletions

View File

@ -663,8 +663,8 @@ void CNode::CloseSocketDisconnect(CConnman* connman)
connman->mapSendableNodes.erase(GetId());
}
if (connman->m_edge_trig_events && !connman->m_edge_trig_events->UnregisterEvents(m_sock->Get())) {
LogPrint(BCLog::NET, "EdgeTriggeredEvents::UnregisterEvents() failed\n");
if (connman->m_edge_trig_events) {
connman->m_edge_trig_events->UnregisterEvents(m_sock->Get());
}
LogPrint(BCLog::NET, "disconnecting peer=%d\n", id);
@ -4310,10 +4310,10 @@ void CConnman::StopNodes()
}
// Close listening sockets.
for (ListenSocket& hListenSocket : vhListenSocket) {
if (hListenSocket.sock) {
if (m_edge_trig_events && !m_edge_trig_events->RemoveSocket(hListenSocket.sock->Get())) {
LogPrintf("EdgeTriggeredEvents::RemoveSocket() failed\n");
if (m_edge_trig_events) {
for (ListenSocket& hListenSocket : vhListenSocket) {
if (hListenSocket.sock) {
m_edge_trig_events->RemoveSocket(hListenSocket.sock->Get());
}
}
}

View File

@ -17,6 +17,7 @@ enum class SocketEventsMode : int8_t;
* A manager for abstracting logic surrounding edge-triggered socket events
* modes like kqueue and epoll.
*/
// TODO: simplify this class to 2-3 flags; kick out everything else to Sock/~Sock and inherited classes
class EdgeTriggeredEvents
{
public: