diff --git a/ChangeLog b/ChangeLog index f2c353cf..741b9dec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-07-11 Tatsuhiro Tsujikawa + + Moved segment empty check before socket check. + * src/AbstractCommand.cc + 2010-07-11 Tatsuhiro Tsujikawa Fixed the bug that segments are not filled to diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index e48b7954..fde9c7e5 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -125,6 +125,27 @@ bool AbstractCommand::execute() { } return prepareForRetry(0); } + if(!getPieceStorage().isNull()) { + segments_.clear(); + getSegmentMan()->getInFlightSegment(segments_, getCuid()); + if(!req_.isNull() && segments_.empty()) { + // This command previously has assigned segments, but it is + // canceled. So discard current request chain. Plus, if no + // segment is available when http pipelining is used. + if(getLogger()->debug()) { + getLogger()->debug("CUID#%s - It seems previously assigned segments" + " are canceled. Restart.", + util::itos(getCuid()).c_str()); + } + // Request::isPipeliningEnabled() == true means aria2 + // accessed the remote server and discovered that the server + // supports pipelining. + if(!req_.isNull() && req_->isPipeliningEnabled()) { + e_->poolSocket(req_, createProxyRequest(), socket_); + } + return prepareForRetry(0); + } + } // TODO it is not needed to check other PeerStats every time. // Find faster Request when no segment is available. if(!req_.isNull() && fileEntry_->countPooledRequest() > 0 && @@ -157,27 +178,6 @@ bool AbstractCommand::execute() { !nameResolverCheck_)) { checkPoint_ = global::wallclock; if(!getPieceStorage().isNull()) { - segments_.clear(); - getSegmentMan()->getInFlightSegment(segments_, getCuid()); - if(!req_.isNull() && segments_.empty()) { - // TODO make this out side of socket check if. - - // This command previously has assigned segments, but it is - // canceled. So discard current request chain. Plus, if no - // segment is available when http pipelining is used. - if(getLogger()->debug()) { - getLogger()->debug("CUID#%s - It seems previously assigned segments" - " are canceled. Restart.", - util::itos(getCuid()).c_str()); - } - // Request::isPipeliningEnabled() == true means aria2 - // accessed the remote server and discovered that the server - // supports pipelining. - if(!req_.isNull() && req_->isPipeliningEnabled()) { - e_->poolSocket(req_, createProxyRequest(), socket_); - } - return prepareForRetry(0); - } if(req_.isNull() || req_->getMaxPipelinedRequest() == 1 || // Why the following condition is necessary? That's because // For single file download, SegmentMan::getSegment(cuid)