diff options
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | src/PeerListenCommand.cc | 2 | ||||
| -rw-r--r-- | src/TorrentMan.cc | 9 |
3 files changed, 15 insertions, 4 deletions
@@ -1,3 +1,11 @@ +2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> + + * TorrentMan.cc: When adding new peer with duplicate = true, if the + number of peer list is equal to or grater than MAX_PEER_LIST, delete + at most 100 failure entry from the list. If with duplicate = false, + MAX_PEER_LIST is not checked. + * PeerListenCommand.cc: Fixed the argument order of log message. + 2006-03-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> * Request.h: Added AFTER_COMPLETED event. diff --git a/src/PeerListenCommand.cc b/src/PeerListenCommand.cc index af680bac..c8f96416 100644 --- a/src/PeerListenCommand.cc +++ b/src/PeerListenCommand.cc @@ -76,7 +76,7 @@ bool PeerListenCommand::execute() { } delete peerSocket; } catch(Exception* ex) { - e->logger->error("CUID#%d - error in accepting connection", cuid, ex); + e->logger->error("CUID#%d - error in accepting connection", ex, cuid); delete ex; if(peerSocket != NULL) { delete peerSocket; diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc index e5b8adbd..43d500dd 100644 --- a/src/TorrentMan.cc +++ b/src/TorrentMan.cc @@ -65,9 +65,6 @@ void TorrentMan::updatePeers(const Peers& peers) { } bool TorrentMan::addPeer(Peer* peer, bool duplicate) { - if(peers.size() >= MAX_PEER_LIST_SIZE) { - return false; - } if(duplicate) { for(Peers::iterator itr = peers.begin(); itr != peers.end(); itr++) { Peer* p = *itr; @@ -76,6 +73,12 @@ bool TorrentMan::addPeer(Peer* peer, bool duplicate) { } } } else { + if(peers.size() >= MAX_PEER_LIST_SIZE) { + deleteOldErrorPeers(100); + if(peers.size() >= MAX_PEER_LIST_SIZE) { + return false; + } + } for(Peers::iterator itr = peers.begin(); itr != peers.end(); itr++) { Peer* p = *itr; if(p->ipaddr == peer->ipaddr && p->port == peer->port) { |
