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/ConnectionImpl.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') 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()); } -- cgit v1.2.1