propagate from branch 'i2p.i2p.zzz.test' (head 1959049922a17635226170bf3309e281d8e02e43)

to branch 'i2p.i2p' (head a06bf8c92a0e1195b6f98dbad3e8898339bc6053)
This commit is contained in:
zzz
2012-01-08 13:16:07 +00:00
54 changed files with 6932 additions and 3841 deletions

View File

@ -241,6 +241,8 @@ public class Router implements RouterClock.ClockShiftListener {
String now = Long.toString(System.currentTimeMillis());
_config.put("router.firstInstalled", now);
_config.put("router.updateLastInstalled", now);
// only compatible with new i2prouter script
_config.put("router.gracefulHUP", "true");
saveConfig();
}
// ********* Start no threads before here ********* //
@ -393,7 +395,7 @@ public class Router implements RouterClock.ClockShiftListener {
_isAlive = true;
_started = _context.clock().now();
try {
Runtime.getRuntime().removeShutdownHook(_shutdownHook);
Runtime.getRuntime().addShutdownHook(_shutdownHook);
} catch (IllegalStateException ise) {}
I2PThread.addOOMEventListener(_oomListener);
@ -1004,9 +1006,12 @@ public class Router implements RouterClock.ClockShiftListener {
/**
* Cancel the JVM runtime hook before calling this.
* Called by the ShutdownHook.
* NOT to be called by others, use shutdown().
*/
public void shutdown2(int exitCode) {
_shutdownInProgress = true;
_log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')');
// So we can get all the way to the end
// No, you can't do Thread.currentThread.setDaemon(false)
if (_killVMOnEnd) {
@ -1021,6 +1026,7 @@ public class Router implements RouterClock.ClockShiftListener {
// Run the shutdown hooks first in case they want to send some goodbye messages
// Maybe we need a delay after this too?
for (Runnable task : _context.getShutdownTasks()) {
//System.err.println("Running shutdown task " + task.getClass());
if (_log.shouldLog(Log.WARN))
_log.warn("Running shutdown task " + task.getClass());
try {
@ -1115,7 +1121,7 @@ public class Router implements RouterClock.ClockShiftListener {
//Runtime.getRuntime().halt(exitCode);
// allow the Runtime shutdown hooks to execute
Runtime.getRuntime().exit(exitCode);
} else {
} else if (System.getProperty("java.vendor").contains("Android")) {
Runtime.getRuntime().gc();
}
}

View File

@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 27;
public final static long BUILD = 0;
/** for example "-test" */
public final static String EXTRA = "-rc";
public final static String EXTRA = "";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION);

View File

@ -32,6 +32,10 @@ public class ShutdownHook extends Thread {
setName("Router " + _id + " shutdown");
Log l = _context.logManager().getLog(Router.class);
l.log(Log.CRIT, "Shutting down the router...");
// Needed to make the wrapper happy, otherwise it gets confused
// and thinks we haven't shut down, possibly because it
// prevents other shutdown hooks from running
_context.router().setKillVMOnEnd(false);
_context.router().shutdown2(Router.EXIT_HARD);
}
}