mirror of https://github.com/aria2/aria2
Retry DHT get_peers task if the number of peers in PeerStorage is less
than max peers. Added virtual size_t countPeer() const to PeerStorage.pull/1/head
parent
aa13ff5f51
commit
70eeebfae9
|
@ -110,9 +110,14 @@ bool DHTGetPeersCommand::execute()
|
||||||
} else if(task_ && task_->finished()) {
|
} else if(task_ && task_->finished()) {
|
||||||
A2_LOG_DEBUG("task finished detected");
|
A2_LOG_DEBUG("task finished detected");
|
||||||
lastGetPeerTime_ = global::wallclock;
|
lastGetPeerTime_ = global::wallclock;
|
||||||
if(numRetry_ < MAX_RETRIES && btRuntime_->lessThanMinPeers()) {
|
if(numRetry_ < MAX_RETRIES &&
|
||||||
|
(btRuntime_->getMaxPeers() == 0 ||
|
||||||
|
btRuntime_->getMaxPeers() > peerStorage_->countPeer())) {
|
||||||
++numRetry_;
|
++numRetry_;
|
||||||
A2_LOG_DEBUG(fmt("Too few peers. Try again(%lu)",
|
A2_LOG_DEBUG(fmt("Too few peers. peers=%lu, max_peers=%lu."
|
||||||
|
" Try again(%lu)",
|
||||||
|
static_cast<unsigned long>(peerStorage_->countPeer()),
|
||||||
|
static_cast<unsigned long>(btRuntime_->getMaxPeers()),
|
||||||
static_cast<unsigned long>(numRetry_)));
|
static_cast<unsigned long>(numRetry_)));
|
||||||
} else {
|
} else {
|
||||||
numRetry_ = 0;
|
numRetry_ = 0;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public:
|
||||||
|
|
||||||
virtual bool addPeer(const SharedHandle<Peer>& peer);
|
virtual bool addPeer(const SharedHandle<Peer>& peer);
|
||||||
|
|
||||||
size_t countPeer() const;
|
virtual size_t countPeer() const;
|
||||||
|
|
||||||
virtual SharedHandle<Peer> getUnusedPeer();
|
virtual SharedHandle<Peer> getUnusedPeer();
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const std::deque<SharedHandle<Peer> >& getPeers() = 0;
|
virtual const std::deque<SharedHandle<Peer> >& getPeers() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of peers.
|
||||||
|
*/
|
||||||
|
virtual size_t countPeer() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns internal dropped peer list.
|
* Returns internal dropped peer list.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,11 @@ public:
|
||||||
return peers;
|
return peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t countPeer() const
|
||||||
|
{
|
||||||
|
return peers.size();
|
||||||
|
}
|
||||||
|
|
||||||
virtual const std::deque<SharedHandle<Peer> >& getDroppedPeers() {
|
virtual const std::deque<SharedHandle<Peer> >& getDroppedPeers() {
|
||||||
return droppedPeers;
|
return droppedPeers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue