From f79a683f342d61434ff7e74e726d18169efeb481 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 27 Oct 2009 17:55:44 +0000 Subject: 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 --- cpp/src/qpid/client/SessionImpl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/client/SessionImpl.cpp') 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) // user thread -- cgit v1.2.1