summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-03-25 19:04:43 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-03-25 19:04:43 +0000
commit1094f309c67696ac12edb3f7847d9c90f770febd (patch)
tree082784a88c673a45a91bbe999ac2a0fa832eec86 /src
parent5fe2e93661c4c76378432710dbedce3a00ae0321 (diff)
* TorrentMan.cc: When adding new peer with duplicate = true, if release-0.3.1
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.
Diffstat (limited to 'src')
-rw-r--r--src/PeerListenCommand.cc2
-rw-r--r--src/TorrentMan.cc9
2 files changed, 7 insertions, 4 deletions
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) {