mirror of https://github.com/aria2/aria2
2008-03-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added summary log for peer announce storage. * src/DHTPeerAnnounceStorage.cc (handleTimeout) Removed cast * src/DefaultPeerStorage.cc (addPeer) Log exception message * src/DHTMessageTracker.cc (handleTimeout) Fixed casting * test/HttpRequestTest.cc * test/MetalinkProcessorTest.cc * test/PieceTest.cc * test/MetalinkEntryTest.cc * test/SequenceTest.ccpull/1/head
parent
3349c7625c
commit
ce5c17f1b3
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2008-03-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Added summary log for peer announce storage.
|
||||
* src/DHTPeerAnnounceStorage.cc (handleTimeout)
|
||||
|
||||
Removed cast
|
||||
* src/DefaultPeerStorage.cc (addPeer)
|
||||
|
||||
Log exception message
|
||||
* src/DHTMessageTracker.cc (handleTimeout)
|
||||
|
||||
Fixed casting
|
||||
* test/HttpRequestTest.cc
|
||||
* test/MetalinkProcessorTest.cc
|
||||
* test/PieceTest.cc
|
||||
* test/MetalinkEntryTest.cc
|
||||
* test/SequenceTest.cc
|
||||
|
||||
2008-03-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
* src/ParameterizedStringParser.cc (createLoop):
|
||||
|
|
|
@ -121,8 +121,8 @@ void DHTMessageTracker::handleTimeout()
|
|||
callback->onTimeout(node);
|
||||
}
|
||||
} catch(RecoverableException* e) {
|
||||
_logger->info("Exception thrown while handling timeouts.", e);
|
||||
delete e;
|
||||
_logger->info("Exception thrown while handling timeouts.");
|
||||
}
|
||||
} else {
|
||||
++i;
|
||||
|
|
|
@ -132,6 +132,7 @@ Peers DHTPeerAnnounceStorage::getPeers(const unsigned char* infoHash)
|
|||
void DHTPeerAnnounceStorage::handleTimeout()
|
||||
{
|
||||
_logger->debug("Now purge peer announces which are timed out.");
|
||||
size_t numPeerAddr = 0;
|
||||
for(std::deque<SharedHandle<DHTPeerAnnounceEntry> >::iterator i = _entries.begin(); i != _entries.end();) {
|
||||
(*i)->removeStalePeerAddrEntry(DHT_PEER_ANNOUNCE_PURGE_INTERVAL);
|
||||
if((*i)->empty()) {
|
||||
|
@ -139,9 +140,12 @@ void DHTPeerAnnounceStorage::handleTimeout()
|
|||
Util::toHex((*i)->getInfoHash(), DHT_ID_LENGTH).c_str());
|
||||
i = _entries.erase(i);
|
||||
} else {
|
||||
numPeerAddr += (*i)->countPeerAddrEntry();
|
||||
++i;
|
||||
}
|
||||
}
|
||||
_logger->debug("Currently %zu peer announce entries, %zu PeerAddr entries",
|
||||
_entries.size(), numPeerAddr);
|
||||
}
|
||||
|
||||
void DHTPeerAnnounceStorage::announcePeer()
|
||||
|
|
|
@ -81,7 +81,7 @@ bool DefaultPeerStorage::addPeer(const PeerHandle& peer) {
|
|||
logger->debug("Adding %s:%u is rejected because it has been already added.", peer->ipaddr.c_str(), peer->port);
|
||||
return false;
|
||||
}
|
||||
if(peers.size() >= (size_t)maxPeerListSize) {
|
||||
if(peers.size() >= maxPeerListSize) {
|
||||
deleteUnusedPeer(peers.size()-maxPeerListSize+1);
|
||||
}
|
||||
peers.push_front(peer);
|
||||
|
|
|
@ -46,43 +46,43 @@ void HttpRequestTest::testGetStartByte()
|
|||
HttpRequest httpRequest;
|
||||
SharedHandle<Segment> segment = new PiecedSegment(1024, new Piece(1, 1024));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)0, httpRequest.getStartByte());
|
||||
CPPUNIT_ASSERT_EQUAL(0LL, httpRequest.getStartByte());
|
||||
|
||||
httpRequest.setSegment(segment);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)1024, httpRequest.getStartByte());
|
||||
CPPUNIT_ASSERT_EQUAL(1024LL, httpRequest.getStartByte());
|
||||
|
||||
}
|
||||
|
||||
void HttpRequestTest::testGetEndByte()
|
||||
{
|
||||
int32_t index = 1;
|
||||
int32_t length = 1024*1024-1024;
|
||||
int32_t segmentLength = 1024*1024;
|
||||
size_t index = 1;
|
||||
size_t length = 1024*1024-1024;
|
||||
size_t segmentLength = 1024*1024;
|
||||
|
||||
HttpRequest httpRequest;
|
||||
SharedHandle<Segment> segment = new PiecedSegment(segmentLength,
|
||||
new Piece(index, length));
|
||||
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)0, httpRequest.getEndByte());
|
||||
CPPUNIT_ASSERT_EQUAL(0LL, httpRequest.getEndByte());
|
||||
|
||||
httpRequest.setSegment(segment);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)0, httpRequest.getEndByte());
|
||||
CPPUNIT_ASSERT_EQUAL(0LL, httpRequest.getEndByte());
|
||||
|
||||
SharedHandle<Request> request = new Request();
|
||||
request->setKeepAlive(true);
|
||||
|
||||
httpRequest.setRequest(request);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)segmentLength*index+length-1,
|
||||
CPPUNIT_ASSERT_EQUAL((off_t)segmentLength*index+length-1,
|
||||
httpRequest.getEndByte());
|
||||
|
||||
|
||||
request->setKeepAlive(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)0, httpRequest.getEndByte());
|
||||
CPPUNIT_ASSERT_EQUAL(0LL, httpRequest.getEndByte());
|
||||
}
|
||||
|
||||
void HttpRequestTest::testCreateRequest()
|
||||
|
@ -475,7 +475,7 @@ void HttpRequestTest::testIsRangeSatisfied()
|
|||
|
||||
CPPUNIT_ASSERT(!httpRequest.isRangeSatisfied(range));
|
||||
|
||||
int64_t entityLength = segment->getSegmentLength()*10;
|
||||
uint64_t entityLength = segment->getSegmentLength()*10;
|
||||
|
||||
range = new Range(segment->getPosition(), 0, entityLength);
|
||||
|
||||
|
|
|
@ -70,11 +70,11 @@ void MetalinkEntryTest::testDropUnsupportedResource() {
|
|||
|
||||
entry->dropUnsupportedResource();
|
||||
#if defined ENABLE_SSL && ENABLE_BITTORRENT
|
||||
CPPUNIT_ASSERT_EQUAL(4, (int)entry->resources.size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, entry->resources.size());
|
||||
#elif defined ENABLE_SSL || ENABLE_BITTORRENT
|
||||
CPPUNIT_ASSERT_EQUAL(3, (int)entry->resources.size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, entry->resources.size());
|
||||
#else
|
||||
CPPUNIT_ASSERT_EQUAL(2, (int)entry->resources.size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry->resources.size());
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
std::deque<SharedHandle<MetalinkResource> >::const_iterator itr =
|
||||
|
@ -99,11 +99,11 @@ void MetalinkEntryTest::testReorderResourcesByPreference() {
|
|||
|
||||
entry->reorderResourcesByPreference();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)100, entry->resources.at(0)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)90, entry->resources.at(1)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)60, entry->resources.at(2)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)50, entry->resources.at(3)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)10, entry->resources.at(4)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(100, entry->resources.at(0)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(90, entry->resources.at(1)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(60, entry->resources.at(2)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(50, entry->resources.at(3)->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(10, entry->resources.at(4)->preference);
|
||||
|
||||
delete entry;
|
||||
}
|
||||
|
@ -119,15 +119,15 @@ void MetalinkEntryTest::testSetLocationPreference()
|
|||
entry->setLocationPreference(locations, 100);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("RO"), entry->resources[0]->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)150, entry->resources[0]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(150, entry->resources[0]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("AT"), entry->resources[1]->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)100, entry->resources[1]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(100, entry->resources[1]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("AL"), entry->resources[2]->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)160, entry->resources[2]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(160, entry->resources[2]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("AD"), entry->resources[3]->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)10, entry->resources[3]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(10, entry->resources[3]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("JP"), entry->resources[4]->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)190, entry->resources[4]->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(190, entry->resources[4]->preference);
|
||||
|
||||
delete entry;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ void MetalinkProcessorTest::testParseFile()
|
|||
SharedHandle<MetalinkResource> resource2 = *resourceItr1;
|
||||
CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_HTTP, resource2->type);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("US"), resource2->location);
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)100, resource2->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(100, resource2->preference);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"),
|
||||
resource2->url);
|
||||
CPPUNIT_ASSERT_EQUAL(-1, resource2->maxConnections);
|
||||
|
|
|
@ -24,7 +24,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( PieceTest );
|
|||
|
||||
void PieceTest::testCompleteBlock()
|
||||
{
|
||||
int32_t blockLength = 32*1024;
|
||||
size_t blockLength = 32*1024;
|
||||
Piece p(0, blockLength*10, blockLength);
|
||||
|
||||
p.completeBlock(5);
|
||||
|
@ -34,7 +34,7 @@ void PieceTest::testCompleteBlock()
|
|||
|
||||
void PieceTest::testGetCompletedLength()
|
||||
{
|
||||
int32_t blockLength = 16*1024;
|
||||
size_t blockLength = 16*1024;
|
||||
Piece p(0, blockLength*10+100, blockLength);
|
||||
|
||||
p.completeBlock(1);
|
||||
|
@ -42,7 +42,7 @@ void PieceTest::testGetCompletedLength()
|
|||
p.completeBlock(9);
|
||||
p.completeBlock(10); // <-- 100 bytes
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)blockLength*3+100, p.getCompletedLength());
|
||||
CPPUNIT_ASSERT_EQUAL(blockLength*3+100, p.getCompletedLength());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(SequenceTest);
|
||||
|
||||
typedef Sequence<int32_t> IntSequence;
|
||||
typedef Sequence<int> IntSequence;
|
||||
|
||||
void SequenceTest::testParseAndNext()
|
||||
{
|
||||
|
@ -31,23 +31,23 @@ void SequenceTest::testParseAndNext()
|
|||
};
|
||||
IntSequence seq = IntSequence(IntSequence::Values(¶ms[0], ¶ms[3]));
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(1, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(3, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(4, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)5, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(5, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)6, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(6, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)7, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(7, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)8, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(8, seq.next());
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)10, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(10, seq.next());
|
||||
CPPUNIT_ASSERT(!seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(0, seq.next());
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ void SequenceTest::testParseAndNext2()
|
|||
};
|
||||
IntSequence seq = IntSequence(IntSequence::Values(¶ms[0], ¶ms[1]));
|
||||
CPPUNIT_ASSERT(seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)1, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(1, seq.next());
|
||||
CPPUNIT_ASSERT(!seq.hasNext());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)0, seq.next());
|
||||
CPPUNIT_ASSERT_EQUAL(0, seq.next());
|
||||
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,11 @@ void SequenceTest::testFlush()
|
|||
IntSequence::Value(10, 11),
|
||||
};
|
||||
IntSequence seq = IntSequence(IntSequence::Values(¶ms[0], ¶ms[3]));
|
||||
std::deque<int32_t> r = seq.flush();
|
||||
std::deque<int> r = seq.flush();
|
||||
|
||||
int32_t answers[] = { 1, 3, 4, 5, 6, 7, 8, 10 };
|
||||
int answers[] = { 1, 3, 4, 5, 6, 7, 8, 10 };
|
||||
|
||||
CPPUNIT_ASSERT(equal(r.begin(), r.end(), &answers[0]));
|
||||
CPPUNIT_ASSERT(std::equal(r.begin(), r.end(), &answers[0]));
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Reference in New Issue