From 6419a424b54eb27d02260de5b73ab3214e1fdd9f Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sun, 12 Sep 2010 12:46:11 +0000 Subject: QPID-2855 : Broker Transport should not block on awaiting session close confirmation git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@996303 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/transport/Session.java | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/transport/Session.java b/java/common/src/main/java/org/apache/qpid/transport/Session.java index 9b84ff422b..e989849477 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Session.java +++ b/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() -- cgit v1.2.1