mirror of https://github.com/aria2/aria2
2009-07-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't call prepareForRetry(1) if all segments are ignored in SegmentMan. * src/AbstractCommand.cc * src/BitfieldMan.cc * src/BitfieldMan.h * src/SegmentMan.cc * src/SegmentMan.hpull/1/head
parent
19913203b7
commit
894641dfdb
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2009-07-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Don't call prepareForRetry(1) if all segments are ignored in
|
||||
SegmentMan.
|
||||
* src/AbstractCommand.cc
|
||||
* src/BitfieldMan.cc
|
||||
* src/BitfieldMan.h
|
||||
* src/SegmentMan.cc
|
||||
* src/SegmentMan.h
|
||||
|
||||
2009-07-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Removed FileEntry::getAssociatedUris()
|
||||
|
|
|
@ -149,7 +149,13 @@ bool AbstractCommand::execute() {
|
|||
if(_segments.empty()) {
|
||||
// TODO socket could be pooled here if pipelining is enabled...
|
||||
logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid);
|
||||
return prepareForRetry(1);
|
||||
// When all segments are ignored in SegmentMan, there are
|
||||
// no URIs available, so don't retry.
|
||||
if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) {
|
||||
return true;
|
||||
} else {
|
||||
return prepareForRetry(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
size_t maxSegments = req->getMaxPipelinedRequest();
|
||||
|
|
|
@ -511,22 +511,37 @@ bool BitfieldMan::isFilteredAllBitSet() const {
|
|||
}
|
||||
}
|
||||
|
||||
bool BitfieldMan::isAllBitSet() const {
|
||||
if(bitfieldLength == 0) {
|
||||
static bool testAllBitSet
|
||||
(const unsigned char* bitfield, size_t length, size_t blocks)
|
||||
{
|
||||
if(length == 0) {
|
||||
return true;
|
||||
}
|
||||
for(size_t i = 0; i < bitfieldLength-1; ++i) {
|
||||
for(size_t i = 0; i < length-1; ++i) {
|
||||
if(bitfield[i] != 0xff) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unsigned char b = ~((128 >> (blocks-1)%8)-1);
|
||||
if(bitfield[bitfieldLength-1] != b) {
|
||||
if(bitfield[length-1] != b) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitfieldMan::isAllBitSet() const
|
||||
{
|
||||
return testAllBitSet(bitfield, bitfieldLength, blocks);
|
||||
}
|
||||
|
||||
bool BitfieldMan::isAllFilterBitSet() const
|
||||
{
|
||||
if(!filterBitfield) {
|
||||
return false;
|
||||
}
|
||||
return testAllBitSet(filterBitfield, bitfieldLength, blocks);
|
||||
}
|
||||
|
||||
bool BitfieldMan::isBitSet(size_t index) const
|
||||
{
|
||||
return bitfield::test(bitfield, blocks, index);
|
||||
|
|
|
@ -209,6 +209,8 @@ public:
|
|||
|
||||
bool isAllBitSet() const;
|
||||
|
||||
bool isAllFilterBitSet() const;
|
||||
|
||||
const unsigned char* getBitfield() const
|
||||
{
|
||||
return bitfield;
|
||||
|
|
|
@ -388,4 +388,9 @@ void SegmentMan::recognizeSegmentFor(const SharedHandle<FileEntry>& fileEntry)
|
|||
_ignoreBitfield.removeFilter(fileEntry->getOffset(), fileEntry->getLength());
|
||||
}
|
||||
|
||||
bool SegmentMan::allSegmentsIgnored() const
|
||||
{
|
||||
return _ignoreBitfield.isAllFilterBitSet();
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -233,6 +233,8 @@ public:
|
|||
|
||||
// Includes segments that fileEntry covers in segment selection.
|
||||
void recognizeSegmentFor(const SharedHandle<FileEntry>& fileEntry);
|
||||
|
||||
bool allSegmentsIgnored() const;
|
||||
};
|
||||
|
||||
typedef SharedHandle<SegmentMan> SegmentManHandle;
|
||||
|
|
Loading…
Reference in New Issue