summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2008-04-21 11:13:52 +0000
committerAidan Skinner <aidan@apache.org>2008-04-21 11:13:52 +0000
commitd28f0eca5aed6d5cb2a36fe3f22b4bd13b133763 (patch)
tree1ed59d46f4253067a96c5d6f5dadb77eaddce218
parentb6e20fbddac23bdee2589d40de9beb3005e36151 (diff)
downloadqpid-python-d28f0eca5aed6d5cb2a36fe3f22b4bd13b133763.tar.gz
QPID-832 Make sure that we lock early enough to avoid deadlocks hwen closing
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/thegreatmerge@650099 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
index 69ddf7b08f..5a05325948 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
@@ -913,31 +913,31 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect
{
synchronized(_sessionCreationLock)
{
- if(!sessions.isEmpty())
- {
- AMQSession session = sessions.remove(0);
- synchronized(session.getMessageDeliveryLock())
- {
- close(sessions, timeout);
- }
- }
- else
+ synchronized (getFailoverMutex())
{
if (!_closed.getAndSet(true))
{
- synchronized (getFailoverMutex())
+ if(!sessions.isEmpty())
+ {
+ AMQSession session = sessions.remove(0);
+ synchronized(session.getMessageDeliveryLock())
+ {
+ close(sessions, timeout);
+ }
+ }
+ else
{
try
{
long startCloseTime = System.currentTimeMillis();
- closeAllSessions(null, timeout, startCloseTime);
+ closeAllSessions(null, timeout, startCloseTime);
- //This MUST occur after we have successfully closed all Channels/Sessions
- _taskPool.shutdown();
+ //This MUST occur after we have successfully closed all Channels/Sessions
+ _taskPool.shutdown();
- if (!_taskPool.isTerminated())
- {
+ if (!_taskPool.isTerminated())
+ {
try
{
// adjust timeout