From e1bcda8c6245035c96bf44ee09d61fa5a52bcafc Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 29 May 2014 17:18:38 -0400
Subject: [PATCH] Merged #93 "Clarify server.threadPoolSize setting documentation"

---
 src/main/java/com/gitblit/manager/ServicesManager.java |   21 ++++++++++++++++++++-
 1 files changed, 20 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..755d8ba 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,9 @@
 	public ServicesManager(IGitblit gitblit) {
 		this.settings = gitblit.getSettings();
 		this.gitblit = gitblit;
+		int defaultThreadPoolSize = settings.getInteger(Keys.execution.defaultThreadPoolSize, 1);
+		this.idGenerator = new IdGenerator();
+		this.workQueue = new WorkQueue(idGenerator, defaultThreadPoolSize);
 	}
 
 	@Override
@@ -99,7 +107,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 +167,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 +243,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