Author: zothar
Date: 2006-06-04 02:58:37 +0000 (Sun, 04 Jun 2006)
New Revision: 9035

Modified:
   trunk/freenet/src/freenet/crypt/DiffieHellman.java
   trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
   trunk/freenet/src/freenet/node/PeerManager.java
Log:
- Do more precalcs in DiffieHellman so PacketSender is less likely to have to 
wait on it.
- Fix indenting on PeerNode.disconnected() since we looked at it for some 
reason on our way through r9033
- Increase MAX_UNMATCHED_FIFO_SIZE again, so we're less likely to go through 
the trouble or receiving (and unencrypting?) messages, just to drop them on the 
floor
- Complain when the workaround in UdpSocketManager.sendPacket() is triggered


Modified: trunk/freenet/src/freenet/crypt/DiffieHellman.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DiffieHellman.java  2006-06-04 02:39:31 UTC 
(rev 9034)
+++ trunk/freenet/src/freenet/crypt/DiffieHellman.java  2006-06-04 02:58:37 UTC 
(rev 9035)
@@ -17,10 +17,10 @@
         * When the number of precalculations falls below this threshold 
generation
         * starts up to make more.
         */
-       private static final int PRECALC_RESUME = 15;
+       private static final int PRECALC_RESUME = 150;

        /** Maximum number of precalculations to create. */
-       private static final int PRECALC_MAX = 30;
+       private static final int PRECALC_MAX = 300;

        /**
         * How often to wake up and make sure the precalculation buffer is full

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2006-06-04 
02:39:31 UTC (rev 9034)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2006-06-04 
02:58:37 UTC (rev 9035)
@@ -43,7 +43,7 @@
        private boolean _active = true;
        private boolean _isDone = false;
        private static UdpSocketManager _usm;
-       private static final int MAX_UNMATCHED_FIFO_SIZE = 5000;
+       private static final int MAX_UNMATCHED_FIFO_SIZE = 50000;

        protected UdpSocketManager() {
        }
@@ -474,11 +474,14 @@
     // I think DNSRequester should have handled DNS for this spot, but
     // I'm seeing this error, so I'm temporarily switching this to
     // allow DNS until I have more time to sort this out  -Zothar (**FIXME**)
-    //if( destination.getAddress(false) == null ) {
-    if( destination.getAddress(true) == null ) {
-                    Logger.error(this, "Tried sending to bad destination 
address: null:" + destination.getPort());
-                    return;
-               }
+    // start with false, and then try true, but complain loudly that we had to 
use true :)
+               if( destination.getAddress(false) == null ) {
+                       Logger.error(this, "Tried sending to destination 
without pre-looked up IP address(needs a real Peer.getHostname()): null:" + 
destination.getPort(), new Exception("error"));
+                       if( destination.getAddress(true) == null ) {
+                               Logger.error(this, "Tried sending to bad 
destination address: null:" + destination.getPort(), new Exception("error"));
+                               return;
+                       }
+               }
                if (_dropProbability > 0) {
                        if (dropRandom.nextInt() % _dropProbability == 0) {
                                Logger.minor(this, "DROPPED: " + 
_sock.getLocalPort() + " -> " + destination.getPort());

Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java     2006-06-04 02:39:31 UTC 
(rev 9034)
+++ trunk/freenet/src/freenet/node/PeerManager.java     2006-06-04 02:58:37 UTC 
(rev 9035)
@@ -154,24 +154,23 @@

        public boolean disconnected(PeerNode pn) {
                synchronized(this) {
-               boolean isInPeers = false;
-               for(int i=0;i<connectedPeers.length;i++) {
-                       if(connectedPeers[i] == pn) isInPeers=true;
+                       boolean isInPeers = false;
+                       for(int i=0;i<connectedPeers.length;i++) {
+                               if(connectedPeers[i] == pn) isInPeers=true;
+                       }
+                       if(!isInPeers) return false;
+                       // removing from connectedPeers
+                       ArrayList a = new ArrayList();
+                       for(int i=0;i<myPeers.length;i++) {
+                               if(myPeers[i]!=pn && myPeers[i].isConnected())
+                                       a.add(myPeers[i]);
+                       }
+                       PeerNode[] newConnectedPeers = new PeerNode[a.size()];
+                       newConnectedPeers = (PeerNode[]) 
a.toArray(newConnectedPeers);
+                       connectedPeers = newConnectedPeers;
                }
-               if(!isInPeers) return false;
-               // removing from connectedPeers
-               ArrayList a = new ArrayList();
-               for(int i=0;i<myPeers.length;i++) {
-                       if(myPeers[i]!=pn && myPeers[i].isConnected())
-                               a.add(myPeers[i]);
-               }
-        
-        PeerNode[] newConnectedPeers = new PeerNode[a.size()];
-        newConnectedPeers = (PeerNode[]) a.toArray(newConnectedPeers);
-           connectedPeers = newConnectedPeers;
-               }
-           checkEmpty();
-           return true;
+               checkEmpty();
+               return true;
        }

     public void addConnectedPeer(PeerNode pn) {


Reply via email to