diff options
author | Alan Conway <aconway@apache.org> | 2008-06-06 20:23:28 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-06-06 20:23:28 +0000 |
commit | fb1f5c770c551fe526adf5b860dd72cf5eb07311 (patch) | |
tree | 79a0d3ccb278e51b9ec5213b038b903d768c2727 /cpp/src/qpid/client/ConnectionImpl.cpp | |
parent | 76c922baf182bb367feed2ec014e7cab9db7f79d (diff) | |
download | qpid-python-fb1f5c770c551fe526adf5b860dd72cf5eb07311.tar.gz |
Added exceptions to sys::Waitable.
Fixed client side deadlock involving client::Bounds.
Fixed incorrect exception messages during connection shutdown.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@664114 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index 81eda0bffb..22f10d3620 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -119,41 +119,32 @@ void ConnectionImpl::close() closed(NORMAL, "Closed by client"); } -// Set closed flags and erase the sessions map, but keep the contents -// so sessions can be updated outside the lock. -ConnectionImpl::SessionVector ConnectionImpl::closeInternal(const Mutex::ScopedLock&) { + +template <class F> void ConnectionImpl::closeInternal(const F& f) { isClosed = true; connector.close(); - SessionVector save; - for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) { + for (SessionMap::iterator i=sessions.begin(); i != sessions.end(); ++i) { boost::shared_ptr<SessionImpl> s = i->second.lock(); - if (s) save.push_back(s); + if (s) f(s); } sessions.clear(); - return save; } -void ConnectionImpl::closed(uint16_t code, const std::string& text) -{ - SessionVector save; - { - Mutex::ScopedLock l(lock); - save = closeInternal(l); - } - std::for_each(save.begin(), save.end(), boost::bind(&SessionImpl::connectionClosed, _1, code, text)); +void ConnectionImpl::closed(uint16_t code, const std::string& text) { + Mutex::ScopedLock l(lock); + setException(new ConnectionException(code, text)); + closeInternal(boost::bind(&SessionImpl::connectionClosed, _1, code, text)); } static const std::string CONN_CLOSED("Connection closed by broker"); -void ConnectionImpl::shutdown() -{ +void ConnectionImpl::shutdown() { Mutex::ScopedLock l(lock); + // FIXME aconway 2008-06-06: exception use, connection-forced is incorrect here. + setException(new ConnectionException(CONNECTION_FORCED, CONN_CLOSED)); if (isClosed) return; - SessionVector save(closeInternal(l)); handler.fail(CONN_CLOSED); - Mutex::ScopedUnlock u(lock); - std::for_each(save.begin(), save.end(), - boost::bind(&SessionImpl::connectionBroke, _1, CONNECTION_FORCED, CONN_CLOSED)); + closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CONNECTION_FORCED, CONN_CLOSED)); } void ConnectionImpl::erase(uint16_t ch) { |