diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-11 07:54:03 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-11 07:54:03 +0000 |
| commit | 0fc900c0acb07320441e2265e6fcd89e80db28b3 (patch) | |
| tree | e846b8e0d718ec6829a215e7a74dd264f638844e /src | |
| parent | a8376a5c4bbdcdae7243f1fbdeb07106a35838db (diff) | |
2009-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that adding 0 length filter to BitfieldMan filters
1 block. It should not filter anything.
* src/BitfieldMan.cc
* src/ConsoleStatCalc.cc
* test/BitfieldManTest.cc
Diffstat (limited to 'src')
| -rw-r--r-- | src/BitfieldMan.cc | 14 | ||||
| -rw-r--r-- | src/ConsoleStatCalc.cc | 12 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index 7940bf25..7421b016 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -33,10 +33,12 @@ */ /* copyright --> */ #include "BitfieldMan.h" + +#include <cstring> + #include "Randomizer.h" #include "Util.h" #include "array_fun.h" -#include <cstring> namespace aria2 { @@ -609,10 +611,12 @@ void BitfieldMan::addFilter(uint64_t offset, uint64_t length) { filterBitfield = new unsigned char[bitfieldLength]; memset(filterBitfield, 0, bitfieldLength); } - size_t startBlock = offset/blockLength; - size_t endBlock = (offset+length-1)/blockLength; - for(size_t i = startBlock; i <= endBlock && i < blocks; i++) { - setFilterBit(i); + if(length > 0) { + size_t startBlock = offset/blockLength; + size_t endBlock = (offset+length-1)/blockLength; + for(size_t i = startBlock; i <= endBlock && i < blocks; i++) { + setFilterBit(i); + } } updateCache(); } diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index 89ba1d4e..cbd43984 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -75,10 +75,14 @@ static void printProgress(std::ostream& o, const SharedHandle<RequestGroup>& rg) #ifdef ENABLE_BITTORRENT if(rg->downloadFinished() && !dynamic_pointer_cast<BtContext>(rg->getDownloadContext()).isNull()) { - o << "SEEDING" << "(" << "ratio:" - << std::fixed << std::setprecision(1) - << ((stat.getAllTimeUploadLength()*10)/rg->getCompletedLength())/10.0 - << ")"; + o << "SEEDING" << "(" << "ratio:"; + if(rg->getCompletedLength() > 0) { + o << std::fixed << std::setprecision(1) + << ((stat.getAllTimeUploadLength()*10)/rg->getCompletedLength())/10.0; + } else { + o << "--"; + } + o << ")"; } else #endif // ENABLE_BITTORRENT { |
