Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,10 +1321,10 @@ void CConnman::ThreadSocketHandler()
}
}

isInSelect = true;
wakeupSelectNeeded = true;
int nSelect = select(have_fds ? hSocketMax + 1 : 0,
&fdsetRecv, &fdsetSend, &fdsetError, &timeout);
isInSelect = false;
wakeupSelectNeeded = false;
if (interruptNet)
return;

Expand Down Expand Up @@ -1521,6 +1521,8 @@ void CConnman::WakeSelect()
LogPrint("net", "write to wakeupPipe failed\n");
}
#endif

wakeupSelectNeeded = false;
}


Expand Down Expand Up @@ -3236,7 +3238,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg, bool allowOpti
if (optimisticSend == true)
nBytesSent = SocketSendData(pnode);
// wake up select() call in case there was no pending data before (so it was not selecting this socket for sending)
else if (!hasPendingData && isInSelect)
else if (!hasPendingData && wakeupSelectNeeded)
WakeSelect();
}
if (nBytesSent)
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class CConnman
/** a pipe which is added to select() calls to wakeup before the timeout */
int wakeupPipe[2]{-1,-1};
#endif
std::atomic<bool> isInSelect{false};
std::atomic<bool> wakeupSelectNeeded{false};

std::thread threadDNSAddressSeed;
std::thread threadSocketHandler;
Expand Down