* AppContext: Add hasWrapper() method

* Shutdown:
    - Clear more resources in peer manager, netdb, stat manager,
      session key manager, naming service, tunnel dispatcher,
      OCMOSJ (result of testing with jvisualvm)
    - Don't call wrapper on shutdown (starting two threads) if we
      were started with runplain
This commit is contained in:
zzz
2011-07-03 13:46:29 +00:00
parent 6074a02cf5
commit 43044586d1
21 changed files with 124 additions and 26 deletions

View File

@ -271,7 +271,7 @@ public class ConfigNetHandler extends FormHandler {
if (switchRequired) {
hiddenSwitch();
} else if (restartRequired) {
if (System.getProperty("wrapper.version") == null) {
if (_context.hasWrapper()) {
// Wow this dumps all conns immediately and really isn't nice
addFormNotice("Performing a soft restart");
_context.router().restart();
@ -289,7 +289,8 @@ public class ConfigNetHandler extends FormHandler {
// There's a few changes that don't really require restart (e.g. enabling inbound TCP)
// But it would be hard to get right, so just do a restart.
addFormError(_("Gracefully restarting I2P to change published router address"));
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
if (_context.hasWrapper())
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}
}
@ -297,6 +298,7 @@ public class ConfigNetHandler extends FormHandler {
private void hiddenSwitch() {
// Full restart required to generate new keys
// FIXME don't call wrapper if not present, only rekey
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}

View File

@ -30,21 +30,25 @@ public class ConfigRestartBean {
if ( (nonce != null) && (systemNonce.equals(nonce)) && (action != null) ) {
// Normal browsers send value, IE sends button label
if ("shutdownImmediate".equals(action) || _("Shutdown immediately", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
if (ctx.hasWrapper())
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
//ctx.router().shutdown(Router.EXIT_HARD); // never returns
ctx.router().shutdownGracefully(Router.EXIT_HARD); // give the UI time to respond
} else if ("cancelShutdown".equals(action) || _("Cancel shutdown", ctx).equals(action) ||
_("Cancel restart", ctx).equals(action)) {
ctx.router().cancelGracefulShutdown();
} else if ("restartImmediate".equals(action) || _("Restart immediately", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
if (ctx.hasWrapper())
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
//ctx.router().shutdown(Router.EXIT_HARD_RESTART); // never returns
ctx.router().shutdownGracefully(Router.EXIT_HARD_RESTART); // give the UI time to respond
} else if ("restart".equals(action) || _("Restart", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
if (ctx.hasWrapper())
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
ctx.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
} else if ("shutdown".equals(action) || _("Shutdown", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
if (ctx.hasWrapper())
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
ctx.router().shutdownGracefully();
}
}
@ -71,7 +75,7 @@ public class ConfigRestartBean {
buf.append("</b></center><br>");
buttons(ctx, buf, urlBase, systemNonce, SET2);
} else {
if (System.getProperty("wrapper.version") != null)
if (ctx.hasWrapper())
buttons(ctx, buf, urlBase, systemNonce, SET3);
else
buttons(ctx, buf, urlBase, systemNonce, SET4);

View File

@ -51,30 +51,38 @@ public class ConfigServiceHandler extends FormHandler {
if (_action == null) return;
if (_("Shutdown gracefully").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
if (_context.hasWrapper())
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
_context.router().shutdownGracefully();
addFormNotice(_("Graceful shutdown initiated"));
} else if (_("Shutdown immediately").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD));
if (_context.hasWrapper())
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD));
_context.router().shutdown(Router.EXIT_HARD);
addFormNotice(_("Shutdown immediately! boom bye bye bad bwoy"));
} else if (_("Cancel graceful shutdown").equals(_action)) {
_context.router().cancelGracefulShutdown();
addFormNotice(_("Graceful shutdown cancelled"));
} else if (_("Graceful restart").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
// should have wrapper if restart button is visible
if (_context.hasWrapper())
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
addFormNotice(_("Graceful restart requested"));
} else if (_("Hard restart").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
// should have wrapper if restart button is visible
if (_context.hasWrapper())
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
_context.router().shutdown(Router.EXIT_HARD_RESTART);
addFormNotice(_("Hard restart requested"));
} else if (_("Rekey and Restart").equals(_action)) {
addFormNotice(_("Rekeying after graceful restart"));
// FIXME don't call wrapper if not present, only rekey
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
} else if (_("Rekey and Shutdown").equals(_action)) {
addFormNotice(_("Rekeying after graceful shutdown"));
// FIXME don't call wrapper if not present, only rekey
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL);
} else if (_("Run I2P on startup").equals(_action)) {

View File

@ -117,7 +117,7 @@ public class ConfigUpdateHelper extends HelperBase {
buf.append(" selected=\"true\"");
buf.append('>').append(_("Download and verify only")).append("</option>");
if (System.getProperty("wrapper.version") != null) {
if (_context.hasWrapper()) {
buf.append("<option value=\"install\"");
if (_dontInstall)
buf.append(" disabled=\"true\"");

View File

@ -115,7 +115,7 @@ public class UnsignedUpdateHandler extends UpdateHandler {
_log.log(Log.CRIT, "Update was downloaded, will be installed at next restart");
StringBuilder buf = new StringBuilder(64);
buf.append("<b>").append(_("Update downloaded")).append("</b><br>");
if (System.getProperty("wrapper.version") != null)
if (_context.hasWrapper())
buf.append(_("Click Restart to install"));
else
buf.append(_("Click Shutdown and restart to install"));

View File

@ -285,7 +285,7 @@ public class UpdateHandler {
_log.log(Log.CRIT, "Update was VERIFIED, will be installed at next restart");
StringBuilder buf = new StringBuilder(64);
buf.append("<b>").append(_("Update downloaded")).append("<br>");
if (System.getProperty("wrapper.version") != null)
if (_context.hasWrapper())
buf.append(_("Click Restart to install"));
else
buf.append(_("Click Shutdown and restart to install"));
@ -312,7 +312,8 @@ public class UpdateHandler {
}
protected void restart() {
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
if (_context.hasWrapper())
_context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}