From 7063609f05d5959f3f8922d4a07285af64469b37 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 10 Oct 2015 13:33:46 +0000 Subject: [PATCH] JobQueue: Only adjust timing for negative clock shifts --- router/java/src/net/i2p/router/JobQueue.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/JobQueue.java b/router/java/src/net/i2p/router/JobQueue.java index b08bf9058..2641707be 100644 --- a/router/java/src/net/i2p/router/JobQueue.java +++ b/router/java/src/net/i2p/router/JobQueue.java @@ -522,6 +522,7 @@ public class JobQueue { _context.clock().addUpdateListener(this); ((RouterClock) _context.clock()).addShiftListener(this); } + public void run() { try { while (_alive) { @@ -591,10 +592,11 @@ public class JobQueue { } catch (InterruptedException ie) {} } // while (_alive) } catch (Throwable t) { - _context.clock().removeUpdateListener(this); - ((RouterClock) _context.clock()).removeShiftListener(this); if (_log.shouldLog(Log.ERROR)) _log.error("pumper killed?!", t); + } finally { + _context.clock().removeUpdateListener(this); + ((RouterClock) _context.clock()).removeShiftListener(this); } } @@ -605,8 +607,20 @@ public class JobQueue { } } + /** + * Clock shift listener. + * Only adjust timings for negative shifts. + * For positive shifts, just wake up the pumper. + * @since 0.9.23 + */ public void clockShift(long delta) { - offsetChanged(delta); + if (delta < 0) { + offsetChanged(delta); + } else { + synchronized (_jobLock) { + _jobLock.notifyAll(); + } + } } }