2008-01-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed the bug that SegmentMan::completeSegment() is not called
	even if Segment is complete when --lowest-speed-limit is 
enabled.
	BUG#1864525
	* src/DownloadCommand.{h, cc}
pull/1/head
Tatsuhiro Tsujikawa 2008-01-06 16:32:52 +00:00
parent 6ab2962655
commit 574e1b3db8
3 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2008-01-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that SegmentMan::completeSegment() is not called
even if Segment is complete when --lowest-speed-limit is enabled.
BUG#1864525
* src/DownloadCommand.{h, cc}
2008-01-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-01-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed: hash algorithm 'sha1' is always used. Fixed: hash algorithm 'sha1' is always used.

View File

@ -118,16 +118,6 @@ bool DownloadCommand::executeInternal() {
//segment->writtenLength += infbufSize; //segment->writtenLength += infbufSize;
peerStat->updateDownloadLength(infbufSize); peerStat->updateDownloadLength(infbufSize);
} }
// calculate downloading speed
if(peerStat->getDownloadStartTime().elapsed(startupIdleTime)) {
int32_t nowSpeed = peerStat->calculateDownloadSpeed();
if(lowestDownloadSpeedLimit > 0 && nowSpeed <= lowestDownloadSpeedLimit) {
throw new DlAbortEx(EX_TOO_SLOW_DOWNLOAD_SPEED,
nowSpeed,
lowestDownloadSpeedLimit,
req->getHost().c_str());
}
}
if(_requestGroup->getTotalLength() != 0 && bufSize == 0) { if(_requestGroup->getTotalLength() != 0 && bufSize == 0) {
throw new DlRetryEx(EX_GOT_EOF); throw new DlRetryEx(EX_GOT_EOF);
} }
@ -137,14 +127,30 @@ bool DownloadCommand::executeInternal() {
if(!transferDecoder.isNull()) transferDecoder->end(); if(!transferDecoder.isNull()) transferDecoder->end();
logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid); logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid);
validatePieceHash(segment); validatePieceHash(segment);
checkLowestDownloadSpeed();
// this unit is going to download another segment. // this unit is going to download another segment.
return prepareForNextSegment(); return prepareForNextSegment();
} else { } else {
checkLowestDownloadSpeed();
e->commands.push_back(this); e->commands.push_back(this);
return false; return false;
} }
} }
void DownloadCommand::checkLowestDownloadSpeed() const
{
// calculate downloading speed
if(peerStat->getDownloadStartTime().elapsed(startupIdleTime)) {
int32_t nowSpeed = peerStat->calculateDownloadSpeed();
if(lowestDownloadSpeedLimit > 0 && nowSpeed <= lowestDownloadSpeedLimit) {
throw new DlAbortEx(EX_TOO_SLOW_DOWNLOAD_SPEED,
nowSpeed,
lowestDownloadSpeedLimit,
req->getHost().c_str());
}
}
}
bool DownloadCommand::prepareForNextSegment() { bool DownloadCommand::prepareForNextSegment() {
if(_requestGroup->downloadFinished()) { if(_requestGroup->downloadFinished()) {
#ifdef ENABLE_MESSAGE_DIGEST #ifdef ENABLE_MESSAGE_DIGEST

View File

@ -51,6 +51,7 @@ private:
void validatePieceHash(const SegmentHandle& segment); void validatePieceHash(const SegmentHandle& segment);
void checkLowestDownloadSpeed() const;
protected: protected:
TransferEncodingHandle transferDecoder; TransferEncodingHandle transferDecoder;