From 3daba4304dba818d54eb9b74d8d35df5aab8fee5 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 22 Nov 2013 10:36:05 -0500 Subject: [PATCH] Add pull request linking in changelog to generated documentation --- src/main/java/com/gitblit/git/GitDaemon.java | 40 +++++++++++++++++++++++++++++----------- 1 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gitblit/git/GitDaemon.java b/src/main/java/com/gitblit/git/GitDaemon.java index 7050f87..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. @@ -178,6 +178,20 @@ } }; } + public int getPort() { + return myAddress.getPort(); + } + + public String formatUrl(String servername, String repository) { + if (getPort() == 9418) { + // standard port + return MessageFormat.format("git://{0}/{1}", servername, repository); + } else { + // non-standard port + return MessageFormat.format("git://{0}:{1,number,0}/{2}", servername, getPort(), repository); + } + } + /** @return timeout (in seconds) before aborting an IO operation. */ public int getTimeout() { return timeout; @@ -185,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 @@ -197,7 +211,7 @@ /** * Start this daemon on a background thread. - * + * * @throws IOException * the server socket could not be opened. * @throws IllegalStateException @@ -214,6 +228,7 @@ run.set(true); acceptSocket = listenSock; acceptThread = new Thread(processors, "Git-Daemon-Accept") { + @Override public void run() { while (isRunning()) { try { @@ -231,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())); } @@ -247,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 @@ -262,6 +277,8 @@ logger.info("Git Daemon stopped."); } catch (InterruptedException e) { logger.error("Accept thread join interrupted", e); + } finally { + acceptThread = null; } } } @@ -274,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