diff options
| author | Alan Conway <aconway@apache.org> | 2007-09-28 17:53:16 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-09-28 17:53:16 +0000 |
| commit | 68c4615c9f0c37d3debfdace0c2169103cf9287d (patch) | |
| tree | 0217ca70a9acf96c810fc15ab888b56e888ca8d6 /cpp/src/qpid/client/ConnectionImpl.cpp | |
| parent | 28b72367e7d93d51c34adf2e7a59da21b20e694d (diff) | |
| download | qpid-python-68c4615c9f0c37d3debfdace0c2169103cf9287d.tar.gz | |
Ensure no danbling pointers in client API:
- Session -shared_ptr-> SessionCore -shared_ptr-> ConnectionImpl
- Connection -shared_ptr-> ConnectionImpl
- ConnectionImpl -weak_ptr-> SessionCore
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@580440 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
| -rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index 43576d2273..fae93e8294 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -45,8 +45,8 @@ ConnectionImpl::ConnectionImpl(boost::shared_ptr<Connector> c) void ConnectionImpl::addSession(const boost::shared_ptr<SessionCore>& session) { Mutex::ScopedLock l(lock); - boost::shared_ptr<SessionCore>& s = sessions[session->getChannel()]; - if (s) + boost::weak_ptr<SessionCore>& s = sessions[session->getChannel()]; + if (s.lock()) throw ChannelBusyException(); s = session; } @@ -61,7 +61,7 @@ void ConnectionImpl::incoming(framing::AMQFrame& frame) boost::shared_ptr<SessionCore> s; { Mutex::ScopedLock l(lock); - s = sessions[frame.getChannel()]; + s = sessions[frame.getChannel()].lock(); } if (!s) throw ChannelErrorException(); @@ -120,7 +120,9 @@ void ConnectionImpl::signalClose(uint16_t code, const std::string& text) { Mutex::ScopedLock l(lock); for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); i++) { - i->second->closed(code, text); + boost::shared_ptr<SessionCore> s = i->second.lock(); + if (s) + s->closed(code, text); } sessions.clear(); isClosed = true; |
