From 020a4d6dccfa25235a1481efc3e449a73a0d659a Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 24 Oct 2013 08:12:03 -0400
Subject: [PATCH] Merge pull request #119 from simonharrer/fix-locale-test-run-bug
---
src/main/java/com/gitblit/git/GitDaemon.java | 30 +++++++++++++++++-------------
1 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/gitblit/git/GitDaemon.java b/src/main/java/com/gitblit/git/GitDaemon.java
index 3c45171..bb578ef 100644
--- a/src/main/java/com/gitblit/git/GitDaemon.java
+++ b/src/main/java/com/gitblit/git/GitDaemon.java
@@ -73,9 +73,9 @@
/**
* Gitblit's Git Daemon ignores any and all per-repository daemon settings and
* integrates into Gitblit's security model.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitDaemon {
@@ -113,7 +113,7 @@
/**
* Construct the Gitblit Git daemon.
- *
+ *
* @param bindInterface
* the ip address of the interface to bind
* @param port
@@ -128,10 +128,10 @@
// set the repository resolver and pack factories
repositoryResolver = new RepositoryResolver<GitDaemonClient>(folder);
}
-
+
/**
* Configure a new daemon for the specified network address.
- *
+ *
* @param addr
* address to listen for connections on. If null, any available
* port will be chosen on all network interfaces.
@@ -177,11 +177,11 @@
}
} };
}
-
+
public int getPort() {
return myAddress.getPort();
}
-
+
public String formatUrl(String servername, String repository) {
if (getPort() == 9418) {
// standard port
@@ -199,7 +199,7 @@
/**
* Set the timeout before willing to abort an IO call.
- *
+ *
* @param seconds
* number of seconds to wait (with no data transfer occurring)
* before aborting an IO read or write operation with the
@@ -211,7 +211,7 @@
/**
* Start this daemon on a background thread.
- *
+ *
* @throws IOException
* the server socket could not be opened.
* @throws IllegalStateException
@@ -228,6 +228,7 @@
run.set(true);
acceptSocket = listenSock;
acceptThread = new Thread(processors, "Git-Daemon-Accept") {
+ @Override
public void run() {
while (isRunning()) {
try {
@@ -245,12 +246,12 @@
//
} finally {
acceptSocket = null;
- acceptThread = null;
}
+
}
};
acceptThread.start();
-
+
logger.info(MessageFormat.format("Git Daemon is listening on {0}:{1,number,0}", myAddress.getAddress().getHostAddress(), myAddress.getPort()));
}
@@ -261,9 +262,9 @@
/** Stop this daemon. */
public synchronized void stop() {
- if (acceptThread != null) {
- logger.info("Git Daemon stopping...");
+ if (isRunning() && acceptThread != null) {
run.set(false);
+ logger.info("Git Daemon stopping...");
try {
// close the accept socket
// this throws a SocketException in the accept thread
@@ -276,6 +277,8 @@
logger.info("Git Daemon stopped.");
} catch (InterruptedException e) {
logger.error("Accept thread join interrupted", e);
+ } finally {
+ acceptThread = null;
}
}
}
@@ -288,6 +291,7 @@
dc.setRemoteAddress(((InetSocketAddress) peer).getAddress());
new Thread(processors, "Git-Daemon-Client " + peer.toString()) {
+ @Override
public void run() {
try {
dc.execute(s);
--
Gitblit v1.9.1