mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 03:49:29 -04:00
Attempt at fixing the Disconnection issue.
* Added DataRate accounting to Relay and Dht. * Rates are exposed through rsDht.h interface. * Added LastIncomingTS() to pqistreamer. * Turned HeartBeat reset() into a warning. * Added NoPacket in 60 sec reset(). * Minor typos/errors corrected. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4818 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7dc0cd6b0f
commit
4aec00a0c2
12 changed files with 212 additions and 9 deletions
|
@ -130,6 +130,10 @@ std::string socket_errorType(int err)
|
|||
{
|
||||
return std::string("ECONNRESET");
|
||||
}
|
||||
else if (err == EHOSTUNREACH)
|
||||
{
|
||||
return std::string("EHOSTUNREACH");
|
||||
}
|
||||
//
|
||||
|
||||
return std::string("UNKNOWN ERROR CODE - ASK RS-DEVS TO ADD IT!");
|
||||
|
|
|
@ -102,7 +102,6 @@ int pqiperson::status()
|
|||
|
||||
int pqiperson::receiveHeartbeat()
|
||||
{
|
||||
//pqioutput(PQL_DEBUG_ALERT, pqipersonzone, "pqiperson::receiveHeartbeat() from peer : " + PeerId());
|
||||
pqioutput(PQL_WARNING, pqipersonzone, "pqiperson::receiveHeartbeat() from peer : " + PeerId());
|
||||
lastHeartbeatReceived = time(NULL);
|
||||
|
||||
|
@ -113,17 +112,34 @@ int pqiperson::receiveHeartbeat()
|
|||
int pqiperson::tick()
|
||||
{
|
||||
//if lastHeartbeatReceived is 0, it might be not activated so don't do a net reset.
|
||||
if (active && (lastHeartbeatReceived != 0) &&
|
||||
if (active && (lastHeartbeatReceived != 0) &&
|
||||
(time(NULL) - lastHeartbeatReceived) > HEARTBEAT_REPEAT_TIME * 5)
|
||||
{
|
||||
int ageLastIncoming = time(NULL) - activepqi->getLastIncomingTS();
|
||||
std::ostringstream out;
|
||||
out << "pqiperson::tick() No heartbeat from the peer, assume connection is dead. calling pqissl::reset(), LastHeartbeat was: ";
|
||||
out << "pqiperson::tick() WARNING No heartbeat from: " << PeerId();
|
||||
//out << " assume dead. calling pqissl::reset(), LastHeartbeat was: ";
|
||||
out << " LastHeartbeat was: ";
|
||||
out << time(NULL) - lastHeartbeatReceived << " secs ago";
|
||||
out << " LastIncoming was: ";
|
||||
out << ageLastIncoming << " secs ago";
|
||||
pqioutput(PQL_WARNING, pqipersonzone, out.str());
|
||||
this->reset();
|
||||
}
|
||||
|
||||
int activeTick = 0;
|
||||
#define NO_PACKET_TIMEOUT 60
|
||||
|
||||
if (ageLastIncoming > NO_PACKET_TIMEOUT)
|
||||
{
|
||||
std::ostringstream out2;
|
||||
out2 << "pqiperson::tick() " << PeerId();
|
||||
out2 << " No Heartbeat & No Packets -> assume dead. calling pqissl::reset()";
|
||||
pqioutput(PQL_WARNING, pqipersonzone, out2.str());
|
||||
|
||||
this->reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int activeTick = 0;
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
|
|
@ -1530,6 +1530,8 @@ int pqissl::senddata(void *data, int len)
|
|||
{
|
||||
out << "SSL_write() SSL_ERROR_SYSCALL ";
|
||||
out << "SOCKET_DEAD -> calling reset()";
|
||||
out << " errno: " << errno;
|
||||
out << " " << socket_errorType(errno);
|
||||
std::cerr << out.str() << std::endl;
|
||||
rslog(RSL_ALERT, pqisslzone, out.str());
|
||||
|
||||
|
@ -1676,7 +1678,9 @@ int pqissl::readdata(void *data, int len)
|
|||
{
|
||||
out << "pqissl::readdata() " << PeerId();
|
||||
out << " SSL_read() SSL_ERROR_SYSCALL";
|
||||
out << "SOCKET_DEAD -> calling reset()";
|
||||
out << " SOCKET_DEAD -> calling reset()";
|
||||
out << " errno: " << errno;
|
||||
out << " " << socket_errorType(errno);
|
||||
rslog(RSL_ALERT, pqisslzone, out.str());
|
||||
|
||||
/* extra debugging - based on SSL_get_error() man page */
|
||||
|
|
|
@ -369,6 +369,8 @@ int pqistreamer::handleincomingitem(RsItem *pqi)
|
|||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
#endif
|
||||
// timestamp last received packet.
|
||||
mLastIncomingTs = time(NULL);
|
||||
|
||||
// Use overloaded Contact function
|
||||
pqi -> PeerId(PeerId());
|
||||
|
@ -376,6 +378,11 @@ int pqistreamer::handleincomingitem(RsItem *pqi)
|
|||
return 1;
|
||||
}
|
||||
|
||||
time_t pqistreamer::getLastIncomingTS()
|
||||
{
|
||||
return mLastIncomingTs;
|
||||
}
|
||||
|
||||
int pqistreamer::handleoutgoing()
|
||||
{
|
||||
RsStackMutex stack(streamerMtx) ; // lock out_pkt and out_data
|
||||
|
|
|
@ -58,6 +58,8 @@ class pqistreamer: public PQInterface
|
|||
virtual int tick();
|
||||
virtual int status();
|
||||
|
||||
time_t getLastIncomingTS(); // Time of last data packet, for checking a connection is alive.
|
||||
|
||||
private:
|
||||
/* Implementation */
|
||||
|
||||
|
@ -113,8 +115,12 @@ class pqistreamer: public PQInterface
|
|||
float avgReadCount;
|
||||
float avgSentCount;
|
||||
|
||||
RsMutex streamerMtx ;
|
||||
// pthread_t thread_id;
|
||||
time_t mLastIncomingTs;
|
||||
|
||||
RsMutex streamerMtx ; // WHAT IS THIS PROTECTING. XXX
|
||||
// pthread_t thread_id;A
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue