[jboss-svn-commits] JBL Code SVN: r28525 - labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 28 04:38:05 EDT 2009


Author: adinn
Date: 2009-07-28 04:38:05 -0400 (Tue, 28 Jul 2009)
New Revision: 28525

Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java
Log:
changed add_connection so that we don't lose track of an open connection if a shutdown occurs between the open and the call to add_conenction

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java	2009-07-28 08:09:22 UTC (rev 28524)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java	2009-07-28 08:38:05 UTC (rev 28525)
@@ -125,7 +125,9 @@
          try
          {
             final Socket conn = _listener_socket.accept();
-            addConnection(conn);
+             // n.b. add may not occur because a shutdown was requested
+            if (addConnection(conn)) {
+                // ok the connection is in the list -- ensure it clears itself out
             Connection.Callback callback = new Connection.Callback() {
                 private Socket _conn = conn;
                 public void run() {
@@ -148,6 +150,7 @@
 	    }
 
             new_conn.start();
+            }
          }
          catch ( final InterruptedIOException ex )
          {
@@ -174,10 +177,22 @@
       }
    }
 
-    public synchronized void addConnection(Socket conn)
+    public synchronized boolean addConnection(Socket conn)
     {
         if (!_stop_listener) {
             connections.add(conn);
+            return true;
+        } else {
+            // a close down request got in between the connection create and the
+            // call to this method. it will have closed all the other connections
+            // and will be waiting on this (listener) thread. so close this connection
+            // before returning false
+            try {
+                conn.close();
+            } catch (Exception e) {
+                // ignore
+            }
+            return false;
         }
     }
 



More information about the jboss-svn-commits mailing list