* Router: Don't let shutdown tasks hang the shutdown

This commit is contained in:
zzz
2012-06-11 20:09:31 +00:00
parent 6e077ee621
commit 6e52ae307c
2 changed files with 10 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
- Reduce delay between peer adds for faster startup
- Thread the announces and reduce timeout when stopping
* NativeBigInteger: Workaround for Raspberry Pi to load the correct lib
* Router: Don't let shutdown tasks hang the shutdown
2012-06-08 zzz
* i2psnark:

View File

@@ -775,7 +775,15 @@ public class Router implements RouterClock.ClockShiftListener {
if (_log.shouldLog(Log.WARN))
_log.warn("Running shutdown task " + task.getClass());
try {
task.run();
//task.run();
Thread t = new Thread(task, "Shutdown task " + task.getClass().getName());
t.setDaemon(true);
t.start();
try {
t.join(10*1000);
} catch (InterruptedException ie) {}
if (t.isAlive())
_log.logAlways(Log.WARN, "Shutdown task took more than 10 seconds to run: " + task.getClass());
} catch (Throwable t) {
_log.log(Log.CRIT, "Error running shutdown task", t);
}