NTCP: Throttle event pumper if looping too fast (tickets #551, #1075, #1411)

This is just a simple workaround, root cause unknown.
May need tuning.
This commit is contained in:
zzz
2015-01-30 16:00:45 +00:00
parent 381dbc4b4a
commit 0671785ab2
3 changed files with 17 additions and 1 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -277,7 +277,19 @@ class EventPumper implements Runnable {
} catch (ClosedSelectorException cse) {
continue;
}
} else {
// another 100% CPU workaround
if ((loopCount % 128) == 127) {
if (_log.shouldLog(Log.WARN))
_log.warn("EventPumper throttle " + loopCount + " loops in " +
(System.currentTimeMillis() - lastFailsafeIteration) + " ms");
try {
Thread.sleep(25);
} catch (InterruptedException ie) {}
}
}
// Clear the cache if the user changes the setting,
// so we can test the effect.
boolean newUseDirect = _context.getBooleanProperty(PROP_DIRECT);