Only run InactivityCheck once per second

This commit is contained in:
Alexander Block 2020-04-07 06:56:25 +02:00
parent 9e57c35e82
commit 65fb8bc454

View File

@ -1660,15 +1660,22 @@ void CConnman::SocketHandler()
} }
} }
InactivityCheck(pnode);
} }
ReleaseNodeVector(vNodesCopy); ReleaseNodeVector(vNodesCopy);
} }
void CConnman::ThreadSocketHandler() void CConnman::ThreadSocketHandler()
{ {
int64_t nLastCleanupNodes = 0;
while (!interruptNet) while (!interruptNet)
{ {
if (GetTimeMillis() - nLastCleanupNodes > 1000) {
ForEachNode(AllNodes, [&](CNode* pnode) {
InactivityCheck(pnode);
});
nLastCleanupNodes = GetTimeMillis();
}
DisconnectNodes(); DisconnectNodes();
NotifyNumConnectionsChanged(); NotifyNumConnectionsChanged();
SocketHandler(); SocketHandler();