mirror of https://github.com/aria2/aria2
Don't retry peer lookup.
We can handle shortage of peer by short interval.pull/1/head
parent
aa4232ca8b
commit
ffce1848ca
|
@ -52,6 +52,16 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
namespace {
|
||||
|
||||
const time_t GET_PEER_INTERVAL = (15*60);
|
||||
// Interval when the size of peer list is low.
|
||||
const time_t GET_PEER_INTERVAL_LOW = (5*60);
|
||||
// Interval when the peer list is empty.
|
||||
const time_t GET_PEER_INTERVAL_ZERO = 60;
|
||||
|
||||
} // namespace
|
||||
|
||||
DHTGetPeersCommand::DHTGetPeersCommand
|
||||
(cuid_t cuid,
|
||||
RequestGroup* requestGroup,
|
||||
|
@ -59,7 +69,6 @@ DHTGetPeersCommand::DHTGetPeersCommand
|
|||
: Command(cuid),
|
||||
requestGroup_(requestGroup),
|
||||
e_(e),
|
||||
numRetry_(0),
|
||||
lastGetPeerTime_(0)
|
||||
{
|
||||
requestGroup_->increaseNumCommand();
|
||||
|
@ -77,8 +86,7 @@ bool DHTGetPeersCommand::execute()
|
|||
}
|
||||
time_t elapsed = lastGetPeerTime_.difference(global::wallclock);
|
||||
if(!task_ &&
|
||||
((numRetry_ > 0 && elapsed >= static_cast<time_t>(numRetry_*5)) ||
|
||||
elapsed >= GET_PEER_INTERVAL ||
|
||||
(elapsed >= GET_PEER_INTERVAL ||
|
||||
(((btRuntime_->lessThanMinPeers() && elapsed >= GET_PEER_INTERVAL_LOW) ||
|
||||
(btRuntime_->getConnections() == 0 &&
|
||||
elapsed >= GET_PEER_INTERVAL_ZERO))
|
||||
|
@ -91,11 +99,6 @@ bool DHTGetPeersCommand::execute()
|
|||
taskQueue_->addPeriodicTask2(task_);
|
||||
} else if(task_ && task_->finished()) {
|
||||
lastGetPeerTime_ = global::wallclock;
|
||||
if(numRetry_ < MAX_RETRIES && btRuntime_->lessThanMinPeers()) {
|
||||
++numRetry_;
|
||||
} else {
|
||||
numRetry_ = 0;
|
||||
}
|
||||
task_.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,14 +52,6 @@ class PeerStorage;
|
|||
|
||||
class DHTGetPeersCommand:public Command {
|
||||
private:
|
||||
static const time_t GET_PEER_INTERVAL = (15*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;
|
||||
|
||||
RequestGroup* requestGroup_;
|
||||
|
||||
SharedHandle<BtRuntime> btRuntime_;
|
||||
|
@ -74,8 +66,6 @@ private:
|
|||
|
||||
SharedHandle<DHTTask> task_;
|
||||
|
||||
size_t numRetry_;
|
||||
|
||||
Timer lastGetPeerTime_;
|
||||
public:
|
||||
DHTGetPeersCommand(cuid_t cuid, RequestGroup* requestGroup,
|
||||
|
|
Loading…
Reference in New Issue