diff options
author | Alan Conway <aconway@apache.org> | 2009-10-26 20:11:08 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-10-26 20:11:08 +0000 |
commit | b6eb88609aea82e676f33ae8ff68918b68b81d33 (patch) | |
tree | 7180c10a249f84f635459086ffab7fe93ece3e01 /cpp/src/qpid/client/SessionImpl.cpp | |
parent | f5c7bf95dd04dc1cf0248511982a18a45847da14 (diff) | |
download | qpid-python-b6eb88609aea82e676f33ae8ff68918b68b81d33.tar.gz |
Separate FailoverListener from client::Connection.
client::ConnectionImpl used to contain a FailoverListener to subscribe
for updates on the amq.failover exchange. This caused some lifecycle
issues including memory leaks.
Now FailoverListener is a public API class that the user must create
associated with a session to get known-broker updates.
Removed the weak_ptr logic in client::SessionImpl which was only
required because of FailoverListener.
Made SessionImpl::close() idempotent. Gets rid of spurious warning
messages in some tests.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@829931 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/SessionImpl.cpp')
-rw-r--r-- | cpp/src/qpid/client/SessionImpl.cpp | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/cpp/src/qpid/client/SessionImpl.cpp b/cpp/src/qpid/client/SessionImpl.cpp index b3181bdb3c..7c807558f0 100644 --- a/cpp/src/qpid/client/SessionImpl.cpp +++ b/cpp/src/qpid/client/SessionImpl.cpp @@ -57,9 +57,7 @@ SessionImpl::SessionImpl(const std::string& name, boost::shared_ptr<ConnectionIm detachedLifetime(0), maxFrameSize(conn->getNegotiatedSettings().maxFrameSize), id(conn->getNegotiatedSettings().username, name.empty() ? Uuid(true).str() : name), - connectionShared(conn), - connectionWeak(conn), - weakPtr(false), + connection(conn), ioHandler(*this), proxy(ioHandler), nextIn(0), @@ -68,7 +66,7 @@ SessionImpl::SessionImpl(const std::string& name, boost::shared_ptr<ConnectionIm doClearDeliveryPropertiesExchange(true), autoDetach(true) { - channel.next = connectionShared.get(); + channel.next = connection.get(); } SessionImpl::~SessionImpl() { @@ -87,8 +85,7 @@ SessionImpl::~SessionImpl() { } delete sendMsgCredit; } - boost::shared_ptr<ConnectionImpl> c = connectionWeak.lock(); - if (c) c->erase(channel); + connection->erase(channel); } @@ -122,6 +119,7 @@ void SessionImpl::open(uint32_t timeout) // user thread void SessionImpl::close() //user thread { Lock l(state); + if (state == DETACHED || state == DETACHING) return; if (detachedLifetime) setTimeout(0); detach(); waitFor(DETACHED); @@ -129,8 +127,6 @@ void SessionImpl::close() //user thread void SessionImpl::resume(boost::shared_ptr<ConnectionImpl>) // user thread { - // weakPtr sessions should not be resumed. - if (weakPtr) return; throw NotImplementedException("Resume not yet implemented by client!"); } @@ -509,11 +505,8 @@ void SessionImpl::proxyOut(AMQFrame& frame) // network thread void SessionImpl::sendFrame(AMQFrame& frame, bool canBlock) { - boost::shared_ptr<ConnectionImpl> c = connectionWeak.lock(); - if (c) { - channel.handle(frame); - c->expand(frame.encodedSize(), canBlock); - } + channel.handle(frame); + connection->expand(frame.encodedSize(), canBlock); } void SessionImpl::deliver(AMQFrame& frame) // network thread @@ -809,17 +802,9 @@ uint32_t SessionImpl::getTimeout() const { return detachedLifetime; } -void SessionImpl::setWeakPtr(bool weak) { - weakPtr = weak; - if (weakPtr) - connectionShared.reset(); // Only keep weak pointer - else - connectionShared = connectionWeak.lock(); -} - boost::shared_ptr<ConnectionImpl> SessionImpl::getConnection() { - return connectionWeak.lock(); + return connection; } void SessionImpl::disableAutoDetach() { autoDetach = false; } |