bugfixes for shutdown and null message reception.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 8 Mar 2007 14:17:10 +0000 (14:17 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 8 Mar 2007 14:17:10 +0000 (14:17 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@354 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/client/picking/PickEndPoint.java
src/uk/ac/vamsas/client/picking/PickServer.java

index 8191a80..c8ebfec 100644 (file)
@@ -117,6 +117,8 @@ class PickEndPoint extends Thread
        {\r
                try\r
                {\r
+      if (str==null || str.length()==1)\r
+        return null;\r
                        if (str.startsWith("CUSTOM"))\r
                                return new CustomMessage(str.substring(6));\r
                \r
index a9e7c1c..b3f54e5 100644 (file)
@@ -19,7 +19,8 @@ class PickServer extends Thread
        private ServerSocket serverSocket;\r
        // Set to true once the server is established\r
        private boolean isServer = false;\r
-       \r
+  // Set to false when server is shutting down\r
+       private boolean isAlive= true;\r
        private SocketManager manager;\r
        \r
        /**\r
@@ -70,14 +71,14 @@ class PickServer extends Thread
                // Loop forever, accepting connectons from other clients\r
                // TODO: add in the ability to terminate the server if a VAMSAS session\r
                // is ended\r
-               while (true)\r
+               while (isAlive)\r
                {\r
                        try\r
                        {\r
                                Socket socket = serverSocket.accept();                          \r
                                logger.info("SERVER: connection detected");\r
-                               \r
-                               manager.addEndPoint(socket);\r
+                               if (isAlive)\r
+                                       manager.addEndPoint(socket);\r
                        }\r
                        catch (IOException e) {}\r
                }\r
@@ -86,7 +87,7 @@ class PickServer extends Thread
        void terminate()\r
        {\r
                logger.info("Server shutting down...");\r
-               \r
+               isAlive=false;\r
                try { serverSocket.close(); }\r
                catch (Exception e)\r
                {\r