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

Skip to content
Snippets Groups Projects
Commit 835ed6d9 authored by zzz's avatar zzz
Browse files

boost priority of shutdown thread

parent 37819286
No related branches found
No related tags found
No related merge requests found
......@@ -766,6 +766,9 @@ public class Router implements RouterClock.ClockShiftListener {
* NOT to be called by others, use shutdown().
*/
public void shutdown2(int exitCode) {
// help us shut down esp. after OOM
int priority = (exitCode == EXIT_OOM) ? Thread.MAX_PRIORITY - 1 : Thread.NORM_PRIORITY + 2;
Thread.currentThread().setPriority(priority);
_shutdownInProgress = true;
_log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')');
// So we can get all the way to the end
......
......@@ -18,6 +18,8 @@ public class OOMListener implements I2PThread.OOMEventListener {
}
public void outOfMemory(OutOfMemoryError oom) {
// boost priority to help us shut down
Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1);
Router.clearCaches();
Log log = _context.logManager().getLog(Router.class);
log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom);
......
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