2008-12-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed the bug that BitTorrent download doesn't finish when
	REJECT message is received before CHOKE message.  The old
	implementation doen't clear the use-bit of the piece when
	recieved REJECT message.
	* src/DefaultBtMessageDispatcher.cc
	* test/DefaultBtMessageDispatcherTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-12-29 13:58:21 +00:00
parent e874b84edd
commit 992f82eb5a
3 changed files with 22 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2008-12-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that BitTorrent download doesn't finish when REJECT
message is received before CHOKE message. The old implementation
doen't clear the use-bit of the piece when recieved REJECT
message.
* src/DefaultBtMessageDispatcher.cc
* test/DefaultBtMessageDispatcherTest.cc
2008-12-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
* Release 1.1.1

View File

@ -408,6 +408,7 @@ void DefaultBtMessageDispatcher::removeOutstandingRequest(const RequestSlot& slo
std::deque<RequestSlot>::iterator i =
std::lower_bound(requestSlots.begin(), requestSlots.end(), slot);
if(i != requestSlots.end() && (*i) == slot) {
AbortOutstandingRequest(slot.getPiece(), cuid)(*i);
requestSlots.erase(i);
}
}

View File

@ -385,16 +385,25 @@ void DefaultBtMessageDispatcherTest::testGetOutstandingRequest() {
}
void DefaultBtMessageDispatcherTest::testRemoveOutstandingRequest() {
RequestSlot slot(1, 1024, 16*1024, 10);
SharedHandle<Piece> piece(new Piece(1, 1024*1024));
size_t blockIndex = 0;
CPPUNIT_ASSERT(piece->getMissingUnusedBlockIndex(blockIndex));
uint32_t begin = blockIndex*piece->getBlockLength();
size_t length = piece->getBlockLength(blockIndex);
RequestSlot slot(piece->getIndex(), begin, length, blockIndex, piece);
btMessageDispatcher->addOutstandingRequest(slot);
RequestSlot s2 = btMessageDispatcher->getOutstandingRequest(1, 1024, 16*1024);
RequestSlot s2 = btMessageDispatcher->getOutstandingRequest
(piece->getIndex(), begin, length);
CPPUNIT_ASSERT(!RequestSlot::isNull(s2));
CPPUNIT_ASSERT(piece->isBlockUsed(blockIndex));
btMessageDispatcher->removeOutstandingRequest(s2);
RequestSlot s3 = btMessageDispatcher->getOutstandingRequest(1, 1024, 16*1024);
RequestSlot s3 = btMessageDispatcher->getOutstandingRequest
(piece->getIndex(), begin, length);
CPPUNIT_ASSERT(RequestSlot::isNull(s3));
CPPUNIT_ASSERT(!piece->isBlockUsed(blockIndex));
}
} // namespace aria2