summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/ConnectionImpl.cpp
diff options
context:
space:
mode:
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()