summaryrefslogtreecommitdiff
path: root/src/FileEntry.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FileEntry.cc')
-rw-r--r--src/FileEntry.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/FileEntry.cc b/src/FileEntry.cc
index f69466b8..50edcfde 100644
--- a/src/FileEntry.cc
+++ b/src/FileEntry.cc
@@ -234,6 +234,9 @@ FileEntry::findFasterRequest
if(lastFasterReplace_.difference(global::wallclock) < startupIdleTime) {
return SharedHandle<Request>();
}
+ std::vector<std::string> inFlightHosts;
+ enumerateInFlightHosts(inFlightRequests_.begin(), inFlightRequests_.end(),
+ std::back_inserter(inFlightHosts));
const SharedHandle<PeerStat>& basestat = base->getPeerStat();
A2_LOG_DEBUG("Search faster server using ServerStat.");
// Use first 10 good URIs to introduce some randomness.
@@ -246,6 +249,13 @@ FileEntry::findFasterRequest
if(!uri::parse(us, *i)) {
continue;
}
+ if(std::count(inFlightHosts.begin(), inFlightHosts.end(),us.host)
+ >= static_cast<int>(maxConnectionPerServer_)) {
+ A2_LOG_DEBUG(fmt("%s has already used %d times, not considered.",
+ (*i).c_str(),
+ static_cast<int>(maxConnectionPerServer_)));
+ continue;
+ }
if(findSecond(usedHosts.begin(), usedHosts.end(), us.host) !=
usedHosts.end()) {
A2_LOG_DEBUG(fmt("%s is in usedHosts, not considered", (*i).c_str()));