Skip to content

Commit 06fa85c

Browse files
committed
[net] InactivityCheck() takes a CNode reference
1 parent e7eb371 commit 06fa85c

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/net.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,35 +1216,35 @@ void CConnman::NotifyNumConnectionsChanged()
12161216
}
12171217
}
12181218

1219-
void CConnman::InactivityCheck(CNode *pnode) const
1219+
void CConnman::InactivityCheck(CNode& node) const
12201220
{
12211221
int64_t nTime = GetSystemTimeInSeconds();
1222-
if (nTime - pnode->nTimeConnected > m_peer_connect_timeout)
1222+
if (nTime - node.nTimeConnected > m_peer_connect_timeout)
12231223
{
1224-
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
1224+
if (node.nLastRecv == 0 || node.nLastSend == 0)
12251225
{
1226-
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d from %d\n", m_peer_connect_timeout, pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->GetId());
1227-
pnode->fDisconnect = true;
1226+
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d from %d\n", m_peer_connect_timeout, node.nLastRecv != 0, node.nLastSend != 0, node.GetId());
1227+
node.fDisconnect = true;
12281228
}
1229-
else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
1229+
else if (nTime - node.nLastSend > TIMEOUT_INTERVAL)
12301230
{
1231-
LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend);
1232-
pnode->fDisconnect = true;
1231+
LogPrintf("socket sending timeout: %is\n", nTime - node.nLastSend);
1232+
node.fDisconnect = true;
12331233
}
1234-
else if (nTime - pnode->nLastRecv > TIMEOUT_INTERVAL)
1234+
else if (nTime - node.nLastRecv > TIMEOUT_INTERVAL)
12351235
{
1236-
LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv);
1237-
pnode->fDisconnect = true;
1236+
LogPrintf("socket receive timeout: %is\n", nTime - node.nLastRecv);
1237+
node.fDisconnect = true;
12381238
}
1239-
else if (pnode->nPingNonceSent && pnode->m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} < GetTime<std::chrono::microseconds>())
1239+
else if (node.nPingNonceSent && node.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} < GetTime<std::chrono::microseconds>())
12401240
{
1241-
LogPrintf("ping timeout: %fs\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - pnode->m_ping_start.load()));
1242-
pnode->fDisconnect = true;
1241+
LogPrintf("ping timeout: %fs\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - node.m_ping_start.load()));
1242+
node.fDisconnect = true;
12431243
}
1244-
else if (!pnode->fSuccessfullyConnected)
1244+
else if (!node.fSuccessfullyConnected)
12451245
{
1246-
LogPrint(BCLog::NET, "version handshake timeout from %d\n", pnode->GetId());
1247-
pnode->fDisconnect = true;
1246+
LogPrint(BCLog::NET, "version handshake timeout from %d\n", node.GetId());
1247+
node.fDisconnect = true;
12481248
}
12491249
}
12501250
}
@@ -1522,7 +1522,7 @@ void CConnman::SocketHandler()
15221522
if (bytes_sent) RecordBytesSent(bytes_sent);
15231523
}
15241524

1525-
InactivityCheck(pnode);
1525+
InactivityCheck(*pnode);
15261526
}
15271527
{
15281528
LOCK(cs_vNodes);

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ class CConnman
10441044
void AcceptConnection(const ListenSocket& hListenSocket);
10451045
void DisconnectNodes();
10461046
void NotifyNumConnectionsChanged();
1047-
void InactivityCheck(CNode *pnode) const;
1047+
void InactivityCheck(CNode& node) const;
10481048
bool GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &send_set, std::set<SOCKET> &error_set);
10491049
void SocketEvents(std::set<SOCKET> &recv_set, std::set<SOCKET> &send_set, std::set<SOCKET> &error_set);
10501050
void SocketHandler();

0 commit comments

Comments
 (0)