Author: toad
Date: 2007-10-26 23:33:13 +0000 (Fri, 26 Oct 2007)
New Revision: 15608
Modified:
trunk/freenet/src/freenet/node/PeerNode.java
Log:
don't send two auth packets to the same IP:port simultaneously
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2007-10-26 23:17:05 UTC
(rev 15607)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2007-10-26 23:33:13 UTC
(rev 15608)
@@ -12,6 +12,7 @@
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
@@ -711,7 +712,8 @@
/**
* Do the maybeUpdateHandshakeIPs DNS requests, but only if
ignoreHostnames is false
- * This method should only be called by maybeUpdateHandshakeIPs
+ * This method should only be called by maybeUpdateHandshakeIPs.
+ * Also removes dupes post-lookup.
*/
private Peer[] updateHandshakeIPs(Peer[] localHandshakeIPs, boolean
ignoreHostnames) {
for(int i=0;i<localHandshakeIPs.length;i++) {
@@ -728,7 +730,11 @@
localHandshakeIPs[i].getHandshakeAddress();
}
}
- return localHandshakeIPs;
+ // De-dupe
+ HashSet ret = new HashSet();
+ for(int i=0;i<localHandshakeIPs.length;i++)
+ ret.add(localHandshakeIPs[i]);
+ return (Peer[]) ret.toArray(new Peer[ret.size()]);
}
/**