update timings

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2656 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-03-28 19:33:33 +00:00
parent 15e85e50f0
commit 4aaf6feffa

View File

@ -73,12 +73,12 @@ const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 6;
* #define P3CONNMGR_NO_AUTO_CONNECTION 1
***/
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 3; /* 2 Seconds? is it be enough! */
const uint32_t P3CONNMGR_UDP_DEFAULT_DELAY = 3; /* 2 Seconds? is it be enough! */
const uint32_t P3CONNMGR_UDP_DEFAULT_PERIOD = 40; //a random timeout is set between P3CONNMGR_UDP_DEFAULT_PERIOD and 2 * P3CONNMGR_UDP_DEFAULT_PERIOD in the implementation
#define MAX_AVAIL_PERIOD 230 //times a peer stay in available state when not connected
#define MIN_RETRY_PERIOD 130
#define MIN_RETRY_PERIOD 140
void printConnectState(peerConnectState &peer);
@ -103,7 +103,7 @@ peerConnectState::peerConnectState()
lastcontact(0),
connecttype(0),
lastavailable(0),
lastattempt(time(NULL) - MIN_RETRY_PERIOD + MIN_TIME_BETWEEN_NET_RESET + 6 + (time(NULL)*1664525 + 1013904223) % 6), //start connection few seconds after the possible next one net reset
lastattempt(time(NULL) - MIN_RETRY_PERIOD + MIN_TIME_BETWEEN_NET_RESET + 6 + rand() % 6), //start connection few seconds after the possible next one net reset
name(""), location(""),
state(0), actions(0),
source(0),
@ -391,7 +391,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 + ((time(NULL)*1664525 + 1013904223) % 6);
it->second.lastattempt = time(NULL) - MIN_RETRY_PERIOD + 6 + rand() % 6;
}
IndicateConfigChanged();
@ -1560,7 +1560,7 @@ bool p3ConnectMgr::connectAttempt(std::string id, struct sockaddr_in &addr,
}
}
it->second.lastattempt = time(NULL) + ((time(NULL)*1664525 + 1013904223) % 6);//add a random perturbation between 0 and 2 sec. pseudo random number generator from Wikipedia/Numerical Recipies.
it->second.lastattempt = time(NULL) + rand() % 6;//add a random perturbation between 0 and 2 sec.
it->second.inConnAttempt = true;
it->second.currentConnAddrAttempt = it->second.connAddrs.front();
it->second.connAddrs.pop_front();
@ -2360,7 +2360,7 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
pca.addr = ipListIt->ipAddr;
pca.type = RS_NET_CONN_TCP_UNKNOW_TOPOLOGY;
//fir the delay, we add a random time and some more time when the friend list is big
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY + (time(NULL)*1664525 + 1013904223) % P3CONNMGR_TCP_DEFAULT_DELAY + (mFriendList.size() / 7);
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY + rand() % 3 + (mFriendList.size() / 5);
pca.ts = time(NULL);
pca.period = 0;
it->second.connAddrs.push_back(pca);
@ -2437,7 +2437,7 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
}
/* flag as last attempt to prevent loop */
it->second.lastattempt = time(NULL) + ((time(NULL)*1664525 + 1013904223) % 6);//add a random perturbation between 0 and 2 sec. pseudo random number generator from Wikipedia/Numerical Recipies.
it->second.lastattempt = time(NULL) + rand() % 6;//add a random perturbation between 0 and 2 sec.
if (it->second.inConnAttempt) {
/* -> it'll automatically use the addresses we added */
@ -2501,7 +2501,7 @@ bool p3ConnectMgr::retryConnectNotify(std::string id)
}
/* flag as last attempt to prevent loop */
it->second.lastattempt = time(NULL) + ((time(NULL)*1664525 + 1013904223) % 6);//add a random perturbation between 0 and 2 sec. pseudo random number generator from Wikipedia/Numerical Recipies.
it->second.lastattempt = time(NULL) + rand() % 6;//add a random perturbation between 0 and 2 sec.
if (ownState.netMode & RS_NET_MODE_UNREACHABLE)
{