[hornetq-commits] JBoss hornetq SVN: r10562 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Apr 27 18:30:19 EDT 2011


Author: clebert.suconic at jboss.com
Date: 2011-04-27 18:30:19 -0400 (Wed, 27 Apr 2011)
New Revision: 10562

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
Log:
Fixing possible dead lock on stomp... (again, not part of the supported source code but I wanted to keep the implementation in sync)

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-04-27 22:29:37 UTC (rev 10561)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2011-04-27 22:30:19 UTC (rev 10562)
@@ -600,51 +600,51 @@
       return new StompFrame(Stomp.Responses.CONNECTED, h);
    }
 
-   public void cleanup(StompConnection connection)
+   public void cleanup(final StompConnection connection)
    {
       connection.setValid(false);
 
-      try
+      // Close the session outside of the lock on the StompConnection, otherwise it could dead lock
+      this.executor.execute(new Runnable()
       {
-         StompSession session = sessions.remove(connection.getID());
-         if (session != null)
+         public void run()
          {
-            try
+            StompSession session = sessions.remove(connection.getID());
+            if (session != null)
             {
-               session.getSession().rollback(true);
-               session.getSession().close(false);
-            }
-            catch (Exception e)
-            {
-               log.warn(e.getMessage(), e);
-            }
-         }
-
-         // removed the transacted session belonging to the connection
-         Iterator<Entry<String, StompSession>> iterator = transactedSessions.entrySet().iterator();
-         while (iterator.hasNext())
-         {
-            Map.Entry<String, StompSession> entry = (Map.Entry<String, StompSession>)iterator.next();
-            if (entry.getValue().getConnection() == connection)
-            {
-               ServerSession serverSession = entry.getValue().getSession();
                try
                {
-                  serverSession.rollback(true);
-                  serverSession.close(false);
+                  session.getSession().rollback(true);
+                  session.getSession().close(false);
                }
                catch (Exception e)
                {
                   log.warn(e.getMessage(), e);
                }
-               iterator.remove();
             }
+
+            // removed the transacted session belonging to the connection
+            Iterator<Entry<String, StompSession>> iterator = transactedSessions.entrySet().iterator();
+            while (iterator.hasNext())
+            {
+               Map.Entry<String, StompSession> entry = (Map.Entry<String, StompSession>)iterator.next();
+               if (entry.getValue().getConnection() == connection)
+               {
+                  ServerSession serverSession = entry.getValue().getSession();
+                  try
+                  {
+                     serverSession.rollback(true);
+                     serverSession.close(false);
+                  }
+                  catch (Exception e)
+                  {
+                     log.warn(e.getMessage(), e);
+                  }
+                  iterator.remove();
+               }
+            }
          }
-      }
-      finally
-      {
-         server.getStorageManager().clearContext();
-      }
+      });
    }
 
    private void sendReply(final StompConnection connection, final StompFrame frame)



More information about the hornetq-commits mailing list