mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-19 11:28:24 -04:00
improved calculation of speed in pqistreamer (was called before only when sending bytes), and prevented situation where no HB is received by the connection is not reset because last HB is 0, causing ghost connected peers in GUI
This commit is contained in:
parent
993d7d4c8f
commit
a5044bd71c
6 changed files with 61 additions and 113 deletions
|
@ -141,9 +141,19 @@ int pqiperson::tick()
|
|||
{
|
||||
RS_STACK_MUTEX(mPersonMtx);
|
||||
|
||||
#ifdef PERSON_DEBUG
|
||||
if(active)
|
||||
{
|
||||
std::cerr << "pqiperson: peer=" << (activepqi? (activepqi->PeerId()): (RsPeerId())) <<", active=" << active << ", last HB=" << time(NULL) - lastHeartbeatReceived << " secs ago." ;
|
||||
if(lastHeartbeatReceived==0)
|
||||
std::cerr << "!!!!!!!" << std::endl;
|
||||
else
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
//if lastHeartbeatReceived is 0, it might be not activated so don't do a net reset.
|
||||
if ( active && (lastHeartbeatReceived != 0)
|
||||
&& (time(NULL) - lastHeartbeatReceived) > HEARTBEAT_REPEAT_TIME * 5)
|
||||
if ( active && time(NULL) > lastHeartbeatReceived + HEARTBEAT_REPEAT_TIME * 5)
|
||||
{
|
||||
int ageLastIncoming = time(NULL) - activepqi->getLastIncomingTS();
|
||||
|
||||
|
@ -157,12 +167,7 @@ int pqiperson::tick()
|
|||
|
||||
if (ageLastIncoming > 60) // Check timeout
|
||||
{
|
||||
#ifdef PERSON_DEBUG
|
||||
std::cerr << "pqiperson::tick() " << PeerId().toStdString()
|
||||
<< " No Heartbeat & No Packets -> assume dead."
|
||||
<< "calling pqissl::reset()" << std::endl;
|
||||
#endif
|
||||
|
||||
std::cerr << "pqiperson::tick() " << PeerId().toStdString() << " No Heartbeat & No Packets for 60 secs -> assume dead." << std::endl;
|
||||
this->reset_locked();
|
||||
}
|
||||
|
||||
|
@ -338,7 +343,7 @@ int pqiperson::handleNotifyEvent_locked(NetInterface *ni, int newState,
|
|||
|
||||
// mark as active.
|
||||
active = true;
|
||||
lastHeartbeatReceived = 0;
|
||||
lastHeartbeatReceived = time(NULL) ;
|
||||
activepqi = pqi;
|
||||
inConnectAttempt = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue