From: jprocter Date: Thu, 8 Mar 2007 14:17:10 +0000 (+0000) Subject: bugfixes for shutdown and null message reception. X-Git-Tag: Release_0.2~166 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=65c6abebf09746acc30b334bc17cd83edac631dd;p=vamsas.git bugfixes for shutdown and null message reception. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@354 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/uk/ac/vamsas/client/picking/PickEndPoint.java b/src/uk/ac/vamsas/client/picking/PickEndPoint.java index 8191a80..c8ebfec 100644 --- a/src/uk/ac/vamsas/client/picking/PickEndPoint.java +++ b/src/uk/ac/vamsas/client/picking/PickEndPoint.java @@ -117,6 +117,8 @@ class PickEndPoint extends Thread { try { + if (str==null || str.length()==1) + return null; if (str.startsWith("CUSTOM")) return new CustomMessage(str.substring(6)); diff --git a/src/uk/ac/vamsas/client/picking/PickServer.java b/src/uk/ac/vamsas/client/picking/PickServer.java index a9e7c1c..b3f54e5 100644 --- a/src/uk/ac/vamsas/client/picking/PickServer.java +++ b/src/uk/ac/vamsas/client/picking/PickServer.java @@ -19,7 +19,8 @@ class PickServer extends Thread private ServerSocket serverSocket; // Set to true once the server is established private boolean isServer = false; - + // Set to false when server is shutting down + private boolean isAlive= true; private SocketManager manager; /** @@ -70,14 +71,14 @@ class PickServer extends Thread // Loop forever, accepting connectons from other clients // TODO: add in the ability to terminate the server if a VAMSAS session // is ended - while (true) + while (isAlive) { try { Socket socket = serverSocket.accept(); logger.info("SERVER: connection detected"); - - manager.addEndPoint(socket); + if (isAlive) + manager.addEndPoint(socket); } catch (IOException e) {} } @@ -86,7 +87,7 @@ class PickServer extends Thread void terminate() { logger.info("Server shutting down..."); - + isAlive=false; try { serverSocket.close(); } catch (Exception e) {