From 7990138bb3eb014c85bfb806c91e23def530ef37 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 31 Oct 2007 18:47:28 +0000 Subject: Simple fix to prevent concurrent disconnection and sending of frames causing seg faults. A more complete solution may follow. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@590786 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/SessionHandler.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cpp/src/qpid/broker/SessionHandler.cpp') diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp index 1d0e67f6ab..0dafcba7bd 100644 --- a/cpp/src/qpid/broker/SessionHandler.cpp +++ b/cpp/src/qpid/broker/SessionHandler.cpp @@ -81,12 +81,14 @@ void SessionHandler::handleIn(AMQFrame& f) { } void SessionHandler::handleOut(AMQFrame& f) { - if (!session.get()) - throw InternalErrorException( - QPID_MSG("attempt to send frame on detached channel.")); - channel.handle(f); // Send it. - if (session->sent(f)) - peerSession.solicitAck(); + ConditionalScopedLock s(suspension); + if (s.lockAcquired() && session.get() && session->isAttached()) { + channel.handle(f); // Send it. + if (session->sent(f)) + peerSession.solicitAck(); + } else { + QPID_LOG(warning, "Dropping frame as session is no longer attached to a channel: " << f); + } } void SessionHandler::assertAttached(const char* method) const { @@ -150,7 +152,8 @@ void SessionHandler::closed(uint16_t replyCode, const string& replyText) { } void SessionHandler::localSuspend() { - if (session.get()) { + ScopedLock s(suspension); + if (session.get() && session->isAttached()) { session->detach(); connection.broker.getSessionManager().suspend(session); } -- cgit v1.2.1