mirror of https://github.com/aria2/aria2
2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Always remove a peer from cache in DefaultPeerStorage::returnPeer(), to make room more fleshy, recently found peers. Peer::_badConditionStartTime is not used anymore. Consider to remove it. * src/DefaultPeerStorage.cc * test/DefaultPeerStorageTest.ccpull/1/head
parent
811649149d
commit
7a74971caa
|
@ -1,3 +1,12 @@
|
|||
2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Always remove a peer from cache in DefaultPeerStorage::returnPeer(),
|
||||
to make room more fleshy, recently found peers.
|
||||
Peer::_badConditionStartTime is not used anymore. Consider to remove
|
||||
it.
|
||||
* src/DefaultPeerStorage.cc
|
||||
* test/DefaultPeerStorageTest.cc
|
||||
|
||||
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Returns cached data only when the previous receiveHandshake() is called
|
||||
|
|
|
@ -244,15 +244,9 @@ void DefaultPeerStorage::returnPeer(const PeerHandle& peer)
|
|||
logger->debug("Cannot find peer %s:%u in PeerStorage.", peer->ipaddr.c_str(), peer->port);
|
||||
} else {
|
||||
onReturningPeer(peer);
|
||||
if((*itr)->port == 0) {
|
||||
|
||||
onErasingPeer(*itr);
|
||||
peers.erase(itr);
|
||||
} else {
|
||||
peer->startBadCondition();
|
||||
peer->resetStatus();
|
||||
peers.erase(itr);
|
||||
peers.push_back(peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -219,13 +219,13 @@ void DefaultPeerStorageTest::testReturnPeer()
|
|||
ps.addPeer(peer2);
|
||||
ps.addPeer(peer3);
|
||||
|
||||
ps.returnPeer(peer2);
|
||||
// peer2 is moved to the end of container
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
||||
ps.getPeers().back()->ipaddr);
|
||||
ps.returnPeer(peer2); // peer2 removed from the container
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, ps.getPeers().size());
|
||||
CPPUNIT_ASSERT(std::find(ps.getPeers().begin(), ps.getPeers().end(), peer2)
|
||||
== ps.getPeers().end());
|
||||
|
||||
ps.returnPeer(peer1); // peer1 is removed from the container
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, ps.getPeers().size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, ps.getPeers().size());
|
||||
CPPUNIT_ASSERT(std::find(ps.getPeers().begin(), ps.getPeers().end(), peer1) == ps.getPeers().end());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue