From b8f8c6129d9a0612b58a2b8bc9d585c50db53d9c Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Tue, 17 Mar 2015 13:17:38 +0000
Subject: [PATCH] prevent negative sleep

---
 .../net/i2p/router/transport/crypto/DHSessionKeyBuilder.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java b/router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java
index 3f55409787..a30215ce36 100644
--- a/router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java
+++ b/router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java
@@ -64,7 +64,7 @@ public class DHSessionKeyBuilder {
     private final static String PROP_DH_PRECALC_DELAY = "crypto.dh.precalc.delay";
     private final static int DEFAULT_DH_PRECALC_MIN = 20;
     private final static int DEFAULT_DH_PRECALC_MAX = 60;
-    private final static int DEFAULT_DH_PRECALC_DELAY = 50;
+    private final static int DEFAULT_DH_PRECALC_DELAY = 25;
 
     /**
      * Create a new public/private value pair for the DH exchange.
@@ -505,7 +505,7 @@ public class DHSessionKeyBuilder {
                         long curCalc = System.currentTimeMillis() - curStart;
                         // for some relief...
                         try {
-                            Thread.sleep(_calcDelay + (curCalc * 3));
+                            Thread.sleep(Math.min(200, Math.max(10, _calcDelay + (curCalc * 3))));
                         } catch (InterruptedException ie) { // nop
                         }
                     }
-- 
GitLab