diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-06-30 17:03:57 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-06-30 17:03:57 +0000 |
| commit | cf19dce8553d8a05f5d307835ea3c429d9eb63f2 (patch) | |
| tree | 7326cc88a21d711218179d722c667dfaeaae249b /src/HttpDownloadCommand.cc | |
| parent | cece2bc896b941d0c9b9d441460b5d32989268bd (diff) | |
2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
HTTP pipelining is now working. Fixed Segmention fault in
BitfieldMan's copy ctor.
* src/AbstractCommand.cc
* src/BitfieldMan.cc
* src/BitfieldMan.h
* src/DownloadCommand.cc
* src/HttpDownloadCommand.cc
* src/HttpRequest.cc
* src/SegmentMan.cc
* src/SegmentMan.h
* test/BitfieldManTest.cc
* test/SegmentManTest.cc
Diffstat (limited to 'src/HttpDownloadCommand.cc')
| -rw-r--r-- | src/HttpDownloadCommand.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index 98ada9eb..048fa8b4 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -80,11 +80,12 @@ bool HttpDownloadCommand::prepareForNextSegment() { e->commands.push_back(command); return true; } else { - if(req->isPipeliningEnabled() || + uint64_t loff = _fileEntry->gtoloff(_segments.front()->getPositionToWrite()); + if((req->isPipeliningEnabled() && loff == _fileEntry->getLength()) || (req->isKeepAliveEnabled() && ((!_transferEncodingDecoder.isNull() && _requestGroup->downloadFinished()) || - static_cast<uint64_t>(_fileEntry->gtoloff(_segments.front()->getPositionToWrite())) == _fileEntry->getLength()))) { + loff == _fileEntry->getLength()))) { e->poolSocket(req, isProxyDefined(), socket); } // The request was sent assuming that server supported pipelining, but @@ -93,11 +94,15 @@ bool HttpDownloadCommand::prepareForNextSegment() { // of the response with the end byte of segment. // If it is the same, HTTP negotiation is necessary for the next request. if(!req->isPipeliningEnabled() && req->isPipeliningHint() && - !_segments.empty() && !downloadFinished) { + !downloadFinished) { const SharedHandle<Segment>& segment = _segments.front(); - if(static_cast<uint64_t>(segment->getPosition())+segment->getLength() == - static_cast<uint64_t>(_httpResponse->getHttpHeader()-> - getRange()->getEndByte()+1)) { + + off_t lastOffset =_fileEntry->gtoloff + (std::min(static_cast<off_t>(segment->getPosition()+segment->getLength()), + _fileEntry->getLastOffset())); + + if(lastOffset == + _httpResponse->getHttpHeader()->getRange()->getEndByte()+1) { return prepareForRetry(0); } } |
