diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-06-05 17:53:32 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-06-05 17:53:32 +0000 |
| commit | 01238260de081423705f65442687af75720acca6 (patch) | |
| tree | e26b5eba7b56a5702b52f317ef367cb5656114ed /qpid/java/common | |
| parent | 955e0ce317d210482226a6481acf460d7da7d913 (diff) | |
| download | qpid-python-01238260de081423705f65442687af75720acca6.tar.gz | |
QPID-1116: fixed a race condition in connection/session close, session close now waits for the session to be detached before returning, this guarantees we won't have any active sessions when the connection close is attempted
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@663677 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common')
| -rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java | 3 | ||||
| -rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java | 21 |
2 files changed, 20 insertions, 4 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java index 5361613e1e..9470520937 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java @@ -42,9 +42,6 @@ class ChannelDelegate extends MethodDelegate<Channel> public @Override void sessionDetached(Channel channel, SessionDetached closed) { channel.getSession().closed(); - // XXX: should we remove the channel from the connection? It - // could have an external reference to it. Maybe we need a - // weak hash map in connection. } public @Override void sessionDetach(Channel channel, SessionDetach dtc) diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java index a7de66c1a7..c11ef46d36 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java @@ -459,7 +459,23 @@ public class Session extends Invoker { sessionRequestTimeout(0); sessionDetach(name); - // XXX: channel.close(); + synchronized (commands) + { + long start = System.currentTimeMillis(); + long elapsed = 0; + try + { + while (!closed.get() && elapsed < timeout) + { + commands.wait(timeout - elapsed); + elapsed = System.currentTimeMillis() - start; + } + } + catch (InterruptedException e) + { + throw new RuntimeException(e); + } + } } public void exception(Throwable t) @@ -484,6 +500,9 @@ public class Session extends Invoker } } } + channel.close(); + channel.setSession(null); + channel = null; } public String toString() |
