qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1539556 - /qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java
Date Thu, 07 Nov 2013 08:44:55 GMT
Author: rgodfrey
Date: Thu Nov  7 08:44:55 2013
New Revision: 1539556

URL: http://svn.apache.org/r1539556
Log:
QPID-5293 : Thread deadlock when closing connection

Modified:
    qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java

Modified: qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java?rev=1539556&r1=1539555&r2=1539556&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ConnectionImpl.java
Thu Nov  7 08:44:55 2013
@@ -341,27 +341,40 @@ public class ConnectionImpl implements C
 
     public void close() throws JMSException
     {
-        synchronized(_lock)
+        Object outerLock;
+        if(_conn != null)
         {
-            if(_state != State.CLOSED)
+            outerLock = _conn.getEndpoint().getLock();
+        }
+        else
+        {
+            outerLock = _lock;
+        }
+
+        synchronized (outerLock)
+        {
+            synchronized(_lock)
             {
-                stop();
-                List<SessionImpl> sessions = new ArrayList<SessionImpl>(_sessions);
-                for(SessionImpl session : sessions)
-                {
-                    session.close();
-                }
-                for(CloseTask task : _closeTasks)
+                if(_state != State.CLOSED)
                 {
-                    task.onClose();
-                }
-                if(_conn != null && _state != State.UNCONNECTED ) {
-                    _conn.close();
+                    stop();
+                    List<SessionImpl> sessions = new ArrayList<SessionImpl>(_sessions);
+                    for(SessionImpl session : sessions)
+                    {
+                        session.close();
+                    }
+                    for(CloseTask task : _closeTasks)
+                    {
+                        task.onClose();
+                    }
+                    if(_conn != null && _state != State.UNCONNECTED ) {
+                        _conn.close();
+                    }
+                    _state = State.CLOSED;
                 }
-                _state = State.CLOSED;
-            }
 
-            _lock.notifyAll();
+                _lock.notifyAll();
+            }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message