From 07eb0963cae3a403f8774f65afa20c940ce7124f Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 13 Jun 2014 08:57:41 -0400 Subject: [PATCH] Merged #103 "flotr2 throws exception on small dashboards" --- src/main/java/com/gitblit/manager/ServicesManager.java | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/gitblit/manager/ServicesManager.java b/src/main/java/com/gitblit/manager/ServicesManager.java index 17724f2..b1c97ba 100644 --- a/src/main/java/com/gitblit/manager/ServicesManager.java +++ b/src/main/java/com/gitblit/manager/ServicesManager.java @@ -47,6 +47,7 @@ import com.gitblit.utils.IdGenerator; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; +import com.gitblit.utils.WorkQueue; /** * Services manager manages long-running services/processes that either have no @@ -66,6 +67,10 @@ private final IGitblit gitblit; + private final IdGenerator idGenerator; + + private final WorkQueue workQueue; + private FanoutService fanoutService; private GitDaemon gitDaemon; @@ -75,6 +80,8 @@ public ServicesManager(IGitblit gitblit) { this.settings = gitblit.getSettings(); this.gitblit = gitblit; + this.idGenerator = new IdGenerator(); + this.workQueue = new WorkQueue(idGenerator, 1); } @Override @@ -99,7 +106,14 @@ if (sshDaemon != null) { sshDaemon.stop(); } + workQueue.stop(); return this; + } + + public boolean isServingRepositories() { + return settings.getBoolean(Keys.git.enableGitServlet, true) + || (gitDaemon != null && gitDaemon.isRunning()) + || (sshDaemon != null && sshDaemon.isRunning()); } protected void configureFederation() { @@ -152,7 +166,7 @@ String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); if (port > 0) { try { - sshDaemon = new SshDaemon(gitblit, new IdGenerator()); + sshDaemon = new SshDaemon(gitblit, workQueue); sshDaemon.start(); } catch (IOException e) { sshDaemon = null; @@ -228,6 +242,10 @@ } public String getSshDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) { + if (user == null || UserModel.ANONYMOUS.equals(user)) { + // SSH always requires authentication - anonymous access prohibited + return null; + } if (sshDaemon != null) { String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); if (bindInterface.equals("localhost") -- Gitblit v1.9.1