summaryrefslogtreecommitdiff
path: root/src/AbstractCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-07-11 14:21:17 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-07-11 14:21:17 +0000
commitf3b097b5af5f720192566cd46f626bbd86c429b9 (patch)
tree7dec29f5a4cba2e360158ab21b00b18193b6e736 /src/AbstractCommand.cc
parentf98a1803236f0065301e545f9a65990aa22b1fcc (diff)
2010-07-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that segments are not filled to Request::getMaxPipelinedRequest(). Make sure that trailing data of transfer encoding is read propery, after file data is received. * src/AbstractCommand.cc * src/DownloadCommand.cc * src/DownloadCommand.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h
Diffstat (limited to 'src/AbstractCommand.cc')
-rw-r--r--src/AbstractCommand.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc
index 0c7c59e0..e48b7954 100644
--- a/src/AbstractCommand.cc
+++ b/src/AbstractCommand.cc
@@ -160,26 +160,43 @@ bool AbstractCommand::execute() {
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.
+ // 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)
+ // is more efficient.
getDownloadContext()->getFileEntries().size() == 1) {
- if(segments_.empty()) {
+ size_t maxSegments = req_.isNull()?1:req_->getMaxPipelinedRequest();
+ while(segments_.size() < maxSegments) {
SharedHandle<Segment> segment =
getSegmentMan()->getSegment(getCuid());
- if(!segment.isNull()) {
+ if(segment.isNull()) {
+ break;
+ } else {
segments_.push_back(segment);
}
}
if(segments_.empty()) {
- // TODO socket could be pooled here if pipelining is enabled...
+ // TODO socket could be pooled here if pipelining is
+ // enabled... Hmm, I don't think if pipelining is enabled
+ // it does not go here.
if(getLogger()->info()) {
getLogger()->info(MSG_NO_SEGMENT_AVAILABLE,
util::itos(getCuid()).c_str());