Procházet zdrojové kódy

* 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.

Tatsuhiro Tsujikawa před 20 roky
rodič
revize
1094f309c6
3 změnil soubory, kde provedl 15 přidání a 4 odebrání
  1. 8 0
      ChangeLog
  2. 1 1
      src/PeerListenCommand.cc
  3. 6 3
      src/TorrentMan.cc

+ 8 - 0
ChangeLog

@@ -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.

+ 1 - 1
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;

+ 6 - 3
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) {