I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 2ba99292 authored by zzz's avatar zzz
Browse files

* PRNG: Move logging from wrapper to router log

parent 616abba3
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import java.util.HashMap; ...@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.util.Log;
/** /**
* fortuna instance that tries to avoid blocking if at all possible by using separate * fortuna instance that tries to avoid blocking if at all possible by using separate
...@@ -17,6 +18,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl ...@@ -17,6 +18,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
private final int status[] = new int[BUFFERS]; private final int status[] = new int[BUFFERS];
private int nextBuf = 0; private int nextBuf = 0;
private I2PAppContext _context; private I2PAppContext _context;
private Log _log;
private static final int STATUS_NEED_FILL = 0; private static final int STATUS_NEED_FILL = 0;
private static final int STATUS_FILLING = 1; private static final int STATUS_FILLING = 1;
...@@ -30,6 +32,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl ...@@ -30,6 +32,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
_context = context; _context = context;
context.statManager().createRateStat("prng.bufferWaitTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); context.statManager().createRateStat("prng.bufferWaitTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } );
context.statManager().createRateStat("prng.bufferFillTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); context.statManager().createRateStat("prng.bufferFillTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } );
_log = context.logManager().getLog(AsyncFortunaStandalone.class);
} }
public void startup() { public void startup() {
...@@ -69,8 +72,8 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl ...@@ -69,8 +72,8 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
waited = System.currentTimeMillis()-before; waited = System.currentTimeMillis()-before;
} }
_context.statManager().addRateData("prng.bufferWaitTime", waited, 0); _context.statManager().addRateData("prng.bufferWaitTime", waited, 0);
if (waited > 10*1000) if (waited > 10*1000 && _log.shouldLog(Log.WARN))
System.out.println(Thread.currentThread().getName() + ": Took " + waited _log.warn(Thread.currentThread().getName() + ": Took " + waited
+ "ms for a full PRNG buffer to be found"); + "ms for a full PRNG buffer to be found");
//System.out.println(Thread.currentThread().getName() + ": Switching to prng buffer " + nextBuf); //System.out.println(Thread.currentThread().getName() + ": Switching to prng buffer " + nextBuf);
buffer = asyncBuffers[nextBuf]; buffer = asyncBuffers[nextBuf];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment