]> source.dussan.org Git - gitblit.git/commitdiff
Fixed GitDaemon stop for unit tests
authorJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 18:51:42 +0000 (14:51 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 18:51:42 +0000 (14:51 -0400)
src/main/java/com/gitblit/git/GitDaemon.java

index 3c45171fd20e16583ffa6cb8b3ae7766631cfbbe..b760fbccb1b12128efb2cc0f19b29942f3860daa 100644 (file)
@@ -245,8 +245,8 @@ public class GitDaemon {
                                        //\r
                                } finally {\r
                                        acceptSocket = null;\r
-                                       acceptThread = null;\r
                                }\r
+\r
                        }\r
                };\r
                acceptThread.start();\r
@@ -261,9 +261,9 @@ public class GitDaemon {
 \r
        /** Stop this daemon. */\r
        public synchronized void stop() {\r
-               if (acceptThread != null) {\r
-                       logger.info("Git Daemon stopping...");\r
+               if (isRunning() && acceptThread != null) {\r
                        run.set(false);\r
+                       logger.info("Git Daemon stopping...");\r
                        try {\r
                                // close the accept socket\r
                                // this throws a SocketException in the accept thread\r
@@ -276,6 +276,8 @@ public class GitDaemon {
                                logger.info("Git Daemon stopped.");\r
                        } catch (InterruptedException e) {\r
                                logger.error("Accept thread join interrupted", e);\r
+                       } finally {\r
+                               acceptThread = null;\r
                        }\r
                }\r
        }\r