summaryrefslogtreecommitdiff
path: root/java/common/src
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-06-05 17:53:32 +0000
committerRafael H. Schloming <rhs@apache.org>2008-06-05 17:53:32 +0000
commitdd3dc7065be453ab3c2ad73aed3ae79c8b162b0d (patch)
treec4197afae5d2a0d2b98ee40f78d608136dd2c3e2 /java/common/src
parentbf9426554e97f42169b19651668ca006df2012df (diff)
downloadqpid-python-dd3dc7065be453ab3c2ad73aed3ae79c8b162b0d.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/qpid@663677 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r--java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java3
-rw-r--r--java/common/src/main/java/org/apache/qpidity/transport/Session.java21
2 files changed, 20 insertions, 4 deletions
diff --git a/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java b/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
index 5361613e1e..9470520937 100644
--- a/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
+++ b/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/java/common/src/main/java/org/apache/qpidity/transport/Session.java b/java/common/src/main/java/org/apache/qpidity/transport/Session.java
index a7de66c1a7..c11ef46d36 100644
--- a/java/common/src/main/java/org/apache/qpidity/transport/Session.java
+++ b/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()