summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/ConnectionImpl.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-12-12 10:50:58 +0000
committerGordon Sim <gsim@apache.org>2007-12-12 10:50:58 +0000
commit45cbaf3bf00000c16163468d77d1363171c69a66 (patch)
tree39b6a8fb33022c0fa2cdf68dc5e2e921bf14d9c5 /cpp/src/qpid/client/ConnectionImpl.cpp
parentc248015f441908139529ce40fee8d43ad3db6dba (diff)
downloadqpid-python-45cbaf3bf00000c16163468d77d1363171c69a66.tar.gz
Fixed deadlock on connection close
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@603551 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
-rw-r--r--cpp/src/qpid/client/ConnectionImpl.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp
index ea467429a1..dd986deec4 100644
--- a/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/cpp/src/qpid/client/ConnectionImpl.cpp
@@ -32,7 +32,7 @@ using namespace qpid::framing;
using namespace qpid::sys;
ConnectionImpl::ConnectionImpl(boost::shared_ptr<Connector> c)
- : connector(c), isClosed(false)
+ : connector(c), isClosed(false), isClosing(false)
{
handler.in = boost::bind(&ConnectionImpl::incoming, this, _1);
handler.out = boost::bind(&Connector::send, connector, _1);
@@ -86,11 +86,21 @@ void ConnectionImpl::open(const std::string& host, int port,
handler.waitForOpen();
}
-void ConnectionImpl::close()
+bool ConnectionImpl::setClosing()
{
Mutex::ScopedLock l(lock);
- if (!isClosed)
+ if (isClosing || isClosed) {
+ return false;
+ }
+ isClosing = true;
+ return true;
+}
+
+void ConnectionImpl::close()
+{
+ if (setClosing()) {
handler.close();
+ }
}
void ConnectionImpl::idleIn()