mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 09:26:18 -05:00
fixed TS in tunnel management
This commit is contained in:
parent
9973978350
commit
c5ba0e975f
@ -40,6 +40,10 @@ RsGxsNetTunnelService::RsGxsNetTunnelService(): mGxsNetTunnelMtx("GxsNetTunnel")
|
|||||||
{
|
{
|
||||||
#warning this is for testing only. In the final version this needs to be initialized with some random content, saved and re-used for a while (e.g. 1 month)
|
#warning this is for testing only. In the final version this needs to be initialized with some random content, saved and re-used for a while (e.g. 1 month)
|
||||||
mRandomBias.clear();
|
mRandomBias.clear();
|
||||||
|
|
||||||
|
mLastKeepAlive = time(NULL) + (lrand48()%20); // adds some variance in order to avoid doing all this tasks at once across services
|
||||||
|
mLastAutoWash = time(NULL) + (lrand48()%20);
|
||||||
|
mLastDump = time(NULL) + (lrand48()%20);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================================================================================//
|
//===========================================================================================================================================//
|
||||||
@ -554,6 +558,8 @@ void RsGxsNetTunnelService::removeVirtualPeer(const TurtleFileHash& hash, const
|
|||||||
#ifdef DEBUG_RSGXSNETTUNNEL
|
#ifdef DEBUG_RSGXSNETTUNNEL
|
||||||
GXS_NET_TUNNEL_DEBUG() << " removing virtual peer " << vpid << " for hash " << hash << std::endl;
|
GXS_NET_TUNNEL_DEBUG() << " removing virtual peer " << vpid << " for hash " << hash << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
mTurtle2GxsPeer.erase(vpid);
|
||||||
|
|
||||||
auto it = mHandledHashes.find(hash) ;
|
auto it = mHandledHashes.find(hash) ;
|
||||||
|
|
||||||
if(it == mHandledHashes.end())
|
if(it == mHandledHashes.end())
|
||||||
@ -616,23 +622,23 @@ void RsGxsNetTunnelService::data_tick()
|
|||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
|
|
||||||
static time_t last_autowash = time(NULL);
|
if(mLastAutoWash + 5 < now)
|
||||||
|
|
||||||
if(last_autowash + 5 < now)
|
|
||||||
{
|
{
|
||||||
autowash();
|
autowash();
|
||||||
last_autowash = now;
|
mLastAutoWash = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t last_dump = time(NULL);
|
if(mLastKeepAlive + 20 < now)
|
||||||
|
|
||||||
if(last_dump + 10 < now)
|
|
||||||
{
|
{
|
||||||
last_dump = now;
|
mLastKeepAlive = now ;
|
||||||
dump();
|
|
||||||
|
|
||||||
sendKeepAlivePackets() ;
|
sendKeepAlivePackets() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mLastDump + 10 < now)
|
||||||
|
{
|
||||||
|
mLastDump = now;
|
||||||
|
dump();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsNetTunnelService::sendKeepAlivePackets()
|
void RsGxsNetTunnelService::sendKeepAlivePackets()
|
||||||
|
@ -274,5 +274,9 @@ private:
|
|||||||
|
|
||||||
friend class RsGxsTunnelRandomBiasItem ;
|
friend class RsGxsTunnelRandomBiasItem ;
|
||||||
friend class StoreHere ;
|
friend class StoreHere ;
|
||||||
|
|
||||||
|
time_t mLastKeepAlive ;
|
||||||
|
time_t mLastAutoWash ;
|
||||||
|
time_t mLastDump ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user