add a modular (with friends number taking into account) retry time for connection attempt

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2991 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-05-24 18:56:11 +00:00
parent c54d581472
commit 7db10d1f6f
2 changed files with 8 additions and 2 deletions

View File

@ -151,6 +151,7 @@ p3ConnectMgr::p3ConnectMgr()
allow_tunnel_connection = true;
mExtAddrFinder = new ExtAddrFinder;
mNetInitTS = 0;
retry_period = MIN_RETRY_PERIOD;
netFlagLocalOk = false;
netFlagUpnpOk = false;
@ -391,7 +392,7 @@ void p3ConnectMgr::netStatusReset()
{
it->second.state &= ~RS_PEER_S_CONNECTED ;
// forces immediate re-connexion in 6 seconds, don't start all connection immediately
it->second.lastattempt = time(NULL) - MIN_RETRY_PERIOD + 6 + rand() % 6;
it->second.lastattempt = time(NULL) - retry_period + 6 + rand() % 6;
}
IndicateConfigChanged();
@ -493,7 +494,7 @@ void p3ConnectMgr::statusTick()
time_t now = time(NULL);
time_t oldavail = now - MAX_AVAIL_PERIOD;
time_t retry = now - MIN_RETRY_PERIOD;
time_t retry = now - retry_period;
{
RsStackMutex stack(connMtx); /****** LOCK MUTEX ******/
@ -2093,6 +2094,9 @@ void p3ConnectMgr::peerConnectRequest(std::string id, struct sockaddr_in radd
bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
{
//set a new retry period, so the more frinds we have the less we launch conection attempts
retry_period = MIN_RETRY_PERIOD + rand() % 3 + (mFriendList.size() * 2);
if (id == AuthSSL::getAuthSSL()->OwnId()) {
#ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::addFriend() cannot add own id as a friend." << std::endl;

View File

@ -377,6 +377,8 @@ private:
p3tunnel *mP3tunnel;
uint32_t retry_period;
std::map<uint32_t, pqiNetAssistFirewall *> mFwAgents;
std::map<uint32_t, pqiNetAssistConnect *> mDhts;