summaryrefslogtreecommitdiff
path: root/src/FileEntry.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-28 21:27:31 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-28 21:27:31 +0900
commit5d498cb1ab70228b60f3ced50e341f71f82a2776 (patch)
treecb65467f262308963ee045810a145afc8cb338d1 /src/FileEntry.cc
parent2906484345007c734c3ff75a6080fbab2d8f1a05 (diff)
Take into account PREF_MAX_CONNECTION_PER_SERVER in
findFasterRequest(...,serverStatMan).
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()));