@@ -1229,6 +1229,39 @@ void CConnman::NotifyNumConnectionsChanged()
1229
1229
}
1230
1230
}
1231
1231
1232
+ void CConnman::InactivityCheck (CNode *pnode)
1233
+ {
1234
+ int64_t nTime = GetSystemTimeInSeconds ();
1235
+ if (nTime - pnode->nTimeConnected > 60 )
1236
+ {
1237
+ if (pnode->nLastRecv == 0 || pnode->nLastSend == 0 )
1238
+ {
1239
+ LogPrint (BCLog::NET, " socket no message in first 60 seconds, %d %d from %d\n " , pnode->nLastRecv != 0 , pnode->nLastSend != 0 , pnode->GetId ());
1240
+ pnode->fDisconnect = true ;
1241
+ }
1242
+ else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
1243
+ {
1244
+ LogPrintf (" socket sending timeout: %is\n " , nTime - pnode->nLastSend );
1245
+ pnode->fDisconnect = true ;
1246
+ }
1247
+ else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90 *60 ))
1248
+ {
1249
+ LogPrintf (" socket receive timeout: %is\n " , nTime - pnode->nLastRecv );
1250
+ pnode->fDisconnect = true ;
1251
+ }
1252
+ else if (pnode->nPingNonceSent && pnode->nPingUsecStart + TIMEOUT_INTERVAL * 1000000 < GetTimeMicros ())
1253
+ {
1254
+ LogPrintf (" ping timeout: %fs\n " , 0.000001 * (GetTimeMicros () - pnode->nPingUsecStart ));
1255
+ pnode->fDisconnect = true ;
1256
+ }
1257
+ else if (!pnode->fSuccessfullyConnected )
1258
+ {
1259
+ LogPrint (BCLog::NET, " version handshake timeout from %d\n " , pnode->GetId ());
1260
+ pnode->fDisconnect = true ;
1261
+ }
1262
+ }
1263
+ }
1264
+
1232
1265
void CConnman::ThreadSocketHandler ()
1233
1266
{
1234
1267
while (!interruptNet)
@@ -1425,38 +1458,7 @@ void CConnman::ThreadSocketHandler()
1425
1458
}
1426
1459
}
1427
1460
1428
- //
1429
- // Inactivity checking
1430
- //
1431
- int64_t nTime = GetSystemTimeInSeconds ();
1432
- if (nTime - pnode->nTimeConnected > 60 )
1433
- {
1434
- if (pnode->nLastRecv == 0 || pnode->nLastSend == 0 )
1435
- {
1436
- LogPrint (BCLog::NET, " socket no message in first 60 seconds, %d %d from %d\n " , pnode->nLastRecv != 0 , pnode->nLastSend != 0 , pnode->GetId ());
1437
- pnode->fDisconnect = true ;
1438
- }
1439
- else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
1440
- {
1441
- LogPrintf (" socket sending timeout: %is\n " , nTime - pnode->nLastSend );
1442
- pnode->fDisconnect = true ;
1443
- }
1444
- else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90 *60 ))
1445
- {
1446
- LogPrintf (" socket receive timeout: %is\n " , nTime - pnode->nLastRecv );
1447
- pnode->fDisconnect = true ;
1448
- }
1449
- else if (pnode->nPingNonceSent && pnode->nPingUsecStart + TIMEOUT_INTERVAL * 1000000 < GetTimeMicros ())
1450
- {
1451
- LogPrintf (" ping timeout: %fs\n " , 0.000001 * (GetTimeMicros () - pnode->nPingUsecStart ));
1452
- pnode->fDisconnect = true ;
1453
- }
1454
- else if (!pnode->fSuccessfullyConnected )
1455
- {
1456
- LogPrint (BCLog::NET, " version handshake timeout from %d\n " , pnode->GetId ());
1457
- pnode->fDisconnect = true ;
1458
- }
1459
- }
1461
+ InactivityCheck (pnode);
1460
1462
}
1461
1463
{
1462
1464
LOCK (cs_vNodes);
0 commit comments