diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2010-09-12 12:46:11 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2010-09-12 12:46:11 +0000 |
commit | f18aee9ca723fe5e5820123999b7f76f30f18acd (patch) | |
tree | 565a7ccd0bb5f7adf6535cfdb26b12f91fce5e83 /qpid/java/common/src/main/java/org/apache | |
parent | cd7dc2d33f55f3d384e4d60e31a1b79a7d11431a (diff) | |
download | qpid-python-f18aee9ca723fe5e5820123999b7f76f30f18acd.tar.gz |
QPID-2855 : Broker Transport should not block on awaiting session close confirmation
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@996303 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common/src/main/java/org/apache')
-rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java index 9b84ff422b..e989849477 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java @@ -543,7 +543,7 @@ public class Session extends SessionInvoker } } - if (state != OPEN && state != CLOSED) + if (state != OPEN && state != CLOSED && state != CLOSING) { Thread current = Thread.currentThread(); if (!current.equals(resumer)) @@ -568,6 +568,7 @@ public class Session extends SessionInvoker ("timed out waiting for resume to finish"); } break; + case CLOSING: case CLOSED: ExecutionException exc = getException(); if (exc != null) @@ -906,18 +907,23 @@ public class Session extends SessionInvoker sessionRequestTimeout(0); sessionDetach(name.getBytes()); - Waiter w = new Waiter(commands, timeout); - while (w.hasTime() && state != CLOSED) - { - w.await(); - } - - if (state != CLOSED) - { - throw new SessionException("close() timed out"); - } + awaitClose(); - connection.removeSession(this); + + } + } + + protected void awaitClose() + { + Waiter w = new Waiter(commands, timeout); + while (w.hasTime() && state != CLOSED) + { + w.await(); + } + + if (state != CLOSED) + { + throw new SessionException("close() timed out"); } } @@ -960,6 +966,16 @@ public class Session extends SessionInvoker delegate.detached(this); } } + + if(state == CLOSED) + { + connection.removeSession(this); + } + } + + public boolean isClosing() + { + return state == CLOSED || state == CLOSING; } public String toString() |