summaryrefslogtreecommitdiff
path: root/src/AbstractCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-12-07 00:32:44 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-12-07 00:32:44 +0900
commit7a0217769840acdde53561330b141607600c286c (patch)
tree818cefe701e90d331547cd36c2773a0c41e43910 /src/AbstractCommand.cc
parent5683f2fb3ee09af4d81260e457c2dcbaf937d157 (diff)
Start to find faster host before the number of missing segments becomes 1
The old implementation starts to find faster host when the number of missing segment becomes 1. Because of --min-split-size option, before the number of missing segment becomes 1, the number of connection becomes 1 and it can be slow. In this case, we have to wait until the last segment is reached. The new implementation starts to find faster host when the remaining length is less than --min-split-size * 2, to mitigate the problem stated above.
Diffstat (limited to 'src/AbstractCommand.cc')
-rw-r--r--src/AbstractCommand.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc
index dc18d97f..632b4969 100644
--- a/src/AbstractCommand.cc
+++ b/src/AbstractCommand.cc
@@ -170,9 +170,10 @@ bool AbstractCommand::execute() {
return prepareForRetry(0);
}
// TODO it is not needed to check other PeerStats every time.
- // Find faster Request when no segment is available.
+ // Find faster Request when no segment split is allowed.
if(req_ && fileEntry_->countPooledRequest() > 0 &&
- !getPieceStorage()->hasMissingUnusedPiece()) {
+ requestGroup_->getTotalLength()-requestGroup_->getCompletedLength()
+ < calculateMinSplitSize()*2) {
SharedHandle<Request> fasterRequest = fileEntry_->findFasterRequest(req_);
if(fasterRequest) {
useFasterRequest(fasterRequest);