diff options
| author | Alan Conway <aconway@apache.org> | 2009-10-27 17:55:44 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2009-10-27 17:55:44 +0000 |
| commit | f79a683f342d61434ff7e74e726d18169efeb481 (patch) | |
| tree | 54bc08e4c2632df0c63ce5353e5ed74ca939ff3a /cpp/src/qpid | |
| parent | 08b92666d3c57c3e897f917d1be2573ceebd4378 (diff) | |
| download | qpid-python-f79a683f342d61434ff7e74e726d18169efeb481.tar.gz | |
Make Session::close and Connection::close no-throw
close() will often be called in destructors and so should not throw exceptions.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@830268 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
| -rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 13 | ||||
| -rw-r--r-- | cpp/src/qpid/client/SessionImpl.cpp | 13 |
2 files changed, 17 insertions, 9 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index c48a580fe8..e4e7b2f5c2 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -188,13 +188,16 @@ void ConnectionImpl::idleOut() void ConnectionImpl::close() { - if (heartbeatTask) { + if (heartbeatTask) heartbeatTask->cancel(); + // close() must be idempotent and no-throw as it will often be called in destructors. + if (handler.isOpen()) { + try { + handler.close(); + closed(CLOSE_CODE_NORMAL, "Closed by client"); + } catch (...) {} } - - if (!handler.isOpen()) return; - handler.close(); - closed(CLOSE_CODE_NORMAL, "Closed by client"); + assert(!handler.isOpen()); } diff --git a/cpp/src/qpid/client/SessionImpl.cpp b/cpp/src/qpid/client/SessionImpl.cpp index 7c807558f0..0f767c9f2e 100644 --- a/cpp/src/qpid/client/SessionImpl.cpp +++ b/cpp/src/qpid/client/SessionImpl.cpp @@ -119,10 +119,15 @@ 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); + // close() must be idempotent and no-throw as it will often be called in destructors. + if (state != DETACHED && state != DETACHING) { + try { + if (detachedLifetime) setTimeout(0); + detach(); + waitFor(DETACHED); + } catch (...) {} + setState(DETACHED); + } } void SessionImpl::resume(boost::shared_ptr<ConnectionImpl>) // user thread |
