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()) {
|
||||
A2_LOG_DEBUG("task finished detected");
|
||||
lastGetPeerTime_ = global::wallclock;
|
||||
if(numRetry_ < MAX_RETRIES && btRuntime_->lessThanMinPeers()) {
|
||||
if(numRetry_ < MAX_RETRIES &&
|
||||
(btRuntime_->getMaxPeers() == 0 ||
|
||||
btRuntime_->getMaxPeers() > peerStorage_->countPeer())) {
|
||||
++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_)));
|
||||
} else {
|
||||
numRetry_ = 0;
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
virtual bool addPeer(const SharedHandle<Peer>& peer);
|
||||
|
||||
size_t countPeer() const;
|
||||
virtual size_t countPeer() const;
|
||||
|
||||
virtual SharedHandle<Peer> getUnusedPeer();
|
||||
|
||||
|
|
|
@ -67,6 +67,12 @@ public:
|
|||
*/
|
||||
virtual const std::deque<SharedHandle<Peer> >& getPeers() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of peers.
|
||||
*/
|
||||
virtual size_t countPeer() const = 0;
|
||||
|
||||
/**
|
||||
* Returns internal dropped peer list.
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,11 @@ public:
|
|||
return peers;
|
||||
}
|
||||
|
||||
virtual size_t countPeer() const
|
||||
{
|
||||
return peers.size();
|
||||
}
|
||||
|
||||
virtual const std::deque<SharedHandle<Peer> >& getDroppedPeers() {
|
||||
return droppedPeers;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue