summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-05-26 21:46:00 +0000
committerAlan Conway <aconway@apache.org>2008-05-26 21:46:00 +0000
commit2f9b9b0a405883ed4fa13c219865726c0b89d86e (patch)
tree3fd6e1bbb9ba2c96468619c89906f761c47ded5a /qpid/cpp
parent920ac8dc4eb1be2b64fda528a9ef52b047532350 (diff)
downloadqpid-python-2f9b9b0a405883ed4fa13c219865726c0b89d86e.tar.gz
Fixed intermittent leak of client::Connector thread.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@660320 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/client/Connection.cpp17
-rw-r--r--qpid/cpp/src/qpid/client/Connection.h2
-rw-r--r--qpid/cpp/src/qpid/client/ConnectionImpl.cpp1
-rw-r--r--qpid/cpp/src/qpid/client/ConnectionImpl.h1
-rw-r--r--qpid/cpp/src/qpid/client/Connector.h2
5 files changed, 12 insertions, 11 deletions
diff --git a/qpid/cpp/src/qpid/client/Connection.cpp b/qpid/cpp/src/qpid/client/Connection.cpp
index bec2b0345d..c108c3c86a 100644
--- a/qpid/cpp/src/qpid/client/Connection.cpp
+++ b/qpid/cpp/src/qpid/client/Connection.cpp
@@ -63,9 +63,13 @@ void Connection::open(
open(settings);
}
+bool Connection::isOpen() const {
+ return impl && impl->isOpen();
+}
+
void Connection::open(const ConnectionSettings& settings)
{
- if (impl)
+ if (isOpen())
throw Exception(QPID_MSG("Connection::open() was already called"));
impl = shared_ptr<ConnectionImpl>(new ConnectionImpl(version, settings));
@@ -74,7 +78,7 @@ void Connection::open(const ConnectionSettings& settings)
}
Session Connection::newSession(const std::string& name) {
- if (!impl)
+ if (!isOpen())
throw Exception(QPID_MSG("Connection has not yet been opened"));
shared_ptr<SessionImpl> simpl(
new SessionImpl(name, impl, ++channelIdCounter, max_frame_size));
@@ -86,8 +90,8 @@ Session Connection::newSession(const std::string& name) {
}
void Connection::resume(Session& session) {
- if (!impl)
- throw Exception(QPID_MSG("Connection has not yet been opened"));
+ if (!isOpen())
+ throw Exception(QPID_MSG("Connection is not open."));
session.impl->setChannel(++channelIdCounter);
impl->addSession(session.impl);
@@ -95,10 +99,7 @@ void Connection::resume(Session& session) {
}
void Connection::close() {
- if (impl) {
- impl->close();
- impl.reset();
- }
+ impl->close();
}
}} // namespace qpid::client
diff --git a/qpid/cpp/src/qpid/client/Connection.h b/qpid/cpp/src/qpid/client/Connection.h
index 5337a20bfa..eb63802161 100644
--- a/qpid/cpp/src/qpid/client/Connection.h
+++ b/qpid/cpp/src/qpid/client/Connection.h
@@ -121,6 +121,8 @@ class Connection
* on a different connection to the one that created it.
*/
void resume(Session& session);
+
+ bool isOpen() const;
};
}} // namespace qpid::client
diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
index bdafa795c2..81eda0bffb 100644
--- a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
@@ -138,7 +138,6 @@ void ConnectionImpl::closed(uint16_t code, const std::string& text)
SessionVector save;
{
Mutex::ScopedLock l(lock);
- if (isClosed) return;
save = closeInternal(l);
}
std::for_each(save.begin(), save.end(), boost::bind(&SessionImpl::connectionClosed, _1, code, text));
diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.h b/qpid/cpp/src/qpid/client/ConnectionImpl.h
index ac28a0f695..655bca359b 100644
--- a/qpid/cpp/src/qpid/client/ConnectionImpl.h
+++ b/qpid/cpp/src/qpid/client/ConnectionImpl.h
@@ -74,6 +74,7 @@ class ConnectionImpl : public Bounds,
~ConnectionImpl();
void open(const std::string& host, int port);
+ bool isOpen() const { return !isClosed && !isClosing; }
void addSession(const boost::shared_ptr<SessionImpl>&);
diff --git a/qpid/cpp/src/qpid/client/Connector.h b/qpid/cpp/src/qpid/client/Connector.h
index ce2b23a32e..f5628b9bcc 100644
--- a/qpid/cpp/src/qpid/client/Connector.h
+++ b/qpid/cpp/src/qpid/client/Connector.h
@@ -126,8 +126,6 @@ class Connector : public framing::OutputHandler,
ConnectionImpl* impl;
- friend class Channel;
-
public:
Connector(framing::ProtocolVersion pVersion,
const ConnectionSettings&,