mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
fix a bug in the udp timeout
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1875 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
671b138111
commit
34c4e500e4
1 changed files with 7 additions and 3 deletions
|
@ -2239,7 +2239,7 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
|
||||||
ipList = it->second.getIpAddressList();
|
ipList = it->second.getIpAddressList();
|
||||||
for (std::list<IpAddressTimed>::iterator ipListIt = ipList.begin(); ipListIt!=(ipList.end()); ipListIt++) {
|
for (std::list<IpAddressTimed>::iterator ipListIt = ipList.begin(); ipListIt!=(ipList.end()); ipListIt++) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::retryConnectTCP() adding ip : " << inet_ntoa(ipListIt->ipAddr.sin_addr);
|
std::cerr << "p3ConnectMgr::retryConnectTCP() adding udp connection attempt : " << inet_ntoa(ipListIt->ipAddr.sin_addr);
|
||||||
std::cerr << ":" << ntohs(ipListIt->ipAddr.sin_port) << std::endl;
|
std::cerr << ":" << ntohs(ipListIt->ipAddr.sin_port) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
//check that the address doens't exist already in the connAddrs
|
//check that the address doens't exist already in the connAddrs
|
||||||
|
@ -2265,7 +2265,7 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
|
||||||
|
|
||||||
if (!found && !isLocal && !isSameSubnet(&ipListIt->ipAddr.sin_addr, &ownState.currentlocaladdr.sin_addr)) {//add only if in different subnet
|
if (!found && !isLocal && !isSameSubnet(&ipListIt->ipAddr.sin_addr, &ownState.currentlocaladdr.sin_addr)) {//add only if in different subnet
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "Adding udp connection attempt." << std::endl;
|
std::cerr << "Adding udp connection attempt.";
|
||||||
#endif
|
#endif
|
||||||
peerConnectAddress pca;
|
peerConnectAddress pca;
|
||||||
pca.addr = ipListIt->ipAddr;
|
pca.addr = ipListIt->ipAddr;
|
||||||
|
@ -2273,9 +2273,13 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
|
||||||
pca.delay = P3CONNMGR_UDP_DEFAULT_DELAY;
|
pca.delay = P3CONNMGR_UDP_DEFAULT_DELAY;
|
||||||
pca.ts = time(NULL);
|
pca.ts = time(NULL);
|
||||||
// pseudo random number generator from Wikipedia/Numerical Recipies.
|
// pseudo random number generator from Wikipedia/Numerical Recipies.
|
||||||
pca.period = P3CONNMGR_UDP_DEFAULT_TIMEOUT + (time(NULL)*1664525 + 1013904223 % P3CONNMGR_UDP_DEFAULT_TIMEOUT); //add a random timeout between 1 and 2 times P3CONNMGR_UDP_DEFAULT_TIMEOUT
|
pca.period = P3CONNMGR_UDP_DEFAULT_TIMEOUT + ((time(NULL)*1664525 + 1013904223) % P3CONNMGR_UDP_DEFAULT_TIMEOUT); //add a random timeout between 1 and 2 times P3CONNMGR_UDP_DEFAULT_TIMEOUT
|
||||||
it->second.connAddrs.push_back(pca);
|
it->second.connAddrs.push_back(pca);
|
||||||
|
|
||||||
|
#ifdef CONN_DEBUG
|
||||||
|
std::cerr << " Udp attempt timeout : " << pca.period << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
break; //add only one udp address
|
break; //add only one udp address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue