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.
pull/36/head
Tatsuhiro Tsujikawa 2012-12-07 00:32:44 +09:00
parent 5683f2fb3e
commit 7a02177698
1 changed files with 3 additions and 2 deletions

View File

@ -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);