Get peers from DHT more frequently when the size of peer list is 0.

pull/1/head
Tatsuhiro Tsujikawa 2011-02-07 00:17:44 +09:00
parent 2666bc8170
commit 8eb1de9ef8
2 changed files with 9 additions and 6 deletions

View File

@ -75,12 +75,13 @@ bool DHTGetPeersCommand::execute()
if(btRuntime_->isHalt()) { if(btRuntime_->isHalt()) {
return true; return true;
} }
time_t elapsed = lastGetPeerTime_.difference(global::wallclock);
if(!task_ && if(!task_ &&
((numRetry_ > 0 && ((numRetry_ > 0 && elapsed >= static_cast<time_t>(numRetry_*5)) ||
lastGetPeerTime_.difference(global::wallclock) >= (time_t)numRetry_*5) || elapsed >= GET_PEER_INTERVAL ||
lastGetPeerTime_.difference(global::wallclock) >= GET_PEER_INTERVAL || (((btRuntime_->lessThanMinPeers() && elapsed >= GET_PEER_INTERVAL_LOW) ||
(btRuntime_->lessThanMinPeers() && (btRuntime_->getConnections() == 0 &&
lastGetPeerTime_.difference(global::wallclock) >= GET_PEER_MIN_INTERVAL elapsed >= GET_PEER_INTERVAL_ZERO))
&& !requestGroup_->downloadFinished()))) { && !requestGroup_->downloadFinished()))) {
A2_LOG_DEBUG(fmt("Issuing PeerLookup for infoHash=%s", A2_LOG_DEBUG(fmt("Issuing PeerLookup for infoHash=%s",
bittorrent::getInfoHashString bittorrent::getInfoHashString

View File

@ -54,7 +54,9 @@ class DHTGetPeersCommand:public Command {
private: private:
static const time_t GET_PEER_INTERVAL = (15*60); static const time_t GET_PEER_INTERVAL = (15*60);
static const time_t GET_PEER_MIN_INTERVAL = (5*60); static const time_t GET_PEER_INTERVAL_LOW = (5*60);
static const time_t GET_PEER_INTERVAL_ZERO = 60;
static const size_t MAX_RETRIES = 10; static const size_t MAX_RETRIES = 10;