diff options
| author | Alan Conway <aconway@apache.org> | 2008-05-26 21:46:00 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-05-26 21:46:00 +0000 |
| commit | 42bac9eab5cc800807a3fa2d8e6c30d5888b209e (patch) | |
| tree | 891845ca754e823c683ff8a888bf1fef66c2ff93 /cpp/src | |
| parent | aaa31ef665147973b3367110db9c0810fb144d9e (diff) | |
| download | qpid-python-42bac9eab5cc800807a3fa2d8e6c30d5888b209e.tar.gz | |
Fixed intermittent leak of client::Connector thread.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@660320 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/qpid/client/Connection.cpp | 17 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connection.h | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 1 | ||||
| -rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.h | 1 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connector.h | 2 |
5 files changed, 12 insertions, 11 deletions
diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index bec2b0345d..c108c3c86a 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/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/cpp/src/qpid/client/Connection.h b/cpp/src/qpid/client/Connection.h index 5337a20bfa..eb63802161 100644 --- a/cpp/src/qpid/client/Connection.h +++ b/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/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index bdafa795c2..81eda0bffb 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/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/cpp/src/qpid/client/ConnectionImpl.h b/cpp/src/qpid/client/ConnectionImpl.h index ac28a0f695..655bca359b 100644 --- a/cpp/src/qpid/client/ConnectionImpl.h +++ b/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/cpp/src/qpid/client/Connector.h b/cpp/src/qpid/client/Connector.h index ce2b23a32e..f5628b9bcc 100644 --- a/cpp/src/qpid/client/Connector.h +++ b/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&, |
