Console: Consolidate timer threads (ticket #1068)

Clear correct property if no users are set
This commit is contained in:
zzz
2017-02-05 20:56:40 +00:00
parent 843b66d61e
commit 36ec4de9c7

View File

@ -19,6 +19,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Timer;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
@ -95,6 +96,7 @@ public class RouterConsoleRunner implements RouterApp {
private final ClientAppManager _mgr; private final ClientAppManager _mgr;
private volatile ClientAppState _state = UNINITIALIZED; private volatile ClientAppState _state = UNINITIALIZED;
private static Server _server; private static Server _server;
private static Timer _jettyTimer;
private String _listenPort; private String _listenPort;
private String _listenHost; private String _listenHost;
private String _sslListenPort; private String _sslListenPort;
@ -235,6 +237,12 @@ public class RouterConsoleRunner implements RouterApp {
PortMapper portMapper = _context.portMapper(); PortMapper portMapper = _context.portMapper();
portMapper.unregister(PortMapper.SVC_CONSOLE); portMapper.unregister(PortMapper.SVC_CONSOLE);
portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE); portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE);
synchronized(RouterConsoleRunner.class) {
if (_jettyTimer != null) {
_jettyTimer.cancel();
_jettyTimer = null;
}
}
changeState(STOPPED); changeState(STOPPED);
} }
@ -846,7 +854,7 @@ public class RouterConsoleRunner implements RouterApp {
Map<String, String> userpw = mgr.getMD5(PROP_CONSOLE_PW); Map<String, String> userpw = mgr.getMD5(PROP_CONSOLE_PW);
if (userpw.isEmpty()) { if (userpw.isEmpty()) {
enable = false; enable = false;
ctx.router().saveConfig(PROP_CONSOLE_PW, "false"); ctx.router().saveConfig(PROP_PW_ENABLE, "false");
} else { } else {
HashLoginService realm = new CustomHashLoginService(JETTY_REALM, context.getContextPath(), HashLoginService realm = new CustomHashLoginService(JETTY_REALM, context.getContextPath(),
ctx.logManager().getLog(RouterConsoleRunner.class)); ctx.logManager().getLog(RouterConsoleRunner.class));
@ -931,8 +939,18 @@ public class RouterConsoleRunner implements RouterApp {
sec.setConstraintMappings(cmarr); sec.setConstraintMappings(cmarr);
context.setSecurityHandler(sec); context.setSecurityHandler(sec);
// No, we can't share the ConstraintSecurityHandler across all webapps
// But we can force all webapps to use a single Timer thread
// see HashSessionManager javadoc
synchronized(RouterConsoleRunner.class) {
if (_jettyTimer == null) {
_jettyTimer = new Timer("Console HashSessionScavenger", true);
}
context.getServletContext().setAttribute("org.eclipse.jetty.server.session.timer", _jettyTimer);
}
} }
/** /**
* For logging authentication failures * For logging authentication failures
* @since 0.9.28 * @since 0.9.28