Author: nextgens
Date: 2007-12-04 23:44:49 +0000 (Tue, 04 Dec 2007)
New Revision: 16290

Modified:
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
JFK: maybe fix the "I dunno about that exponential" bug

Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-12-04 
22:27:48 UTC (rev 16289)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-12-04 
23:44:49 UTC (rev 16290)
@@ -80,9 +80,16 @@
                JFK_PREFIX_RESPONDER = R;
        }

+       /* How often shall we generate a new exponential and add it to the 
FIFO? */
+       public final static int DH_GENERATION_INTERVAL = 30000; // 30sec
+       /* How big is the FIFO? */
        public final static int DH_CONTEXT_BUFFER_SIZE = 10;
+       /*
+       * The FIFO itself
+       * Get a lock on dhContextFIFO before touching it!
+       */
        private final LinkedList dhContextFIFO = new LinkedList();
-       /* Get a lock on dhContextFIFO before touching it! */
+       /* The element which is about to be prunned from the FIFO */
        private DiffieHellmanLightContext dhContextToBePrunned = null;
        private long jfkDHLastGenerationTimestamp = 0;

@@ -479,7 +486,7 @@
                if(logMINOR) Logger.minor(this, "Sending a JFK(1) message to 
"+pn);
                final long now = System.currentTimeMillis();
                DiffieHellmanLightContext ctx = (DiffieHellmanLightContext) 
pn.getKeyAgreementSchemeContext();
-               if((ctx == null) || ((pn.jfkContextLifetime + 15*60*1000) < 
now)) {
+               if((ctx == null) || ((pn.jfkContextLifetime + 
DH_GENERATION_INTERVAL*DH_CONTEXT_BUFFER_SIZE) < now)) {
                        pn.jfkContextLifetime = now;
                        pn.setKeyAgreementSchemeContext(ctx = 
getLightDiffieHellmanContext());
                }
@@ -2226,7 +2233,7 @@
                        result = (DiffieHellmanLightContext) 
dhContextFIFO.removeFirst();

                        // Shall we replace one element of the queue ?
-                       if((jfkDHLastGenerationTimestamp + 30000 /*30sec*/) < 
now) {
+                       if((jfkDHLastGenerationTimestamp + 
DH_GENERATION_INTERVAL) < now) {
                                jfkDHLastGenerationTimestamp = now;
                                _fillJFKDHFIFOOffThread();
                        }


Reply via email to