diff options
author | Gordon Sim <gsim@apache.org> | 2007-10-31 18:47:28 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-10-31 18:47:28 +0000 |
commit | 7990138bb3eb014c85bfb806c91e23def530ef37 (patch) | |
tree | 50179d4837d87f9e7f079ca44088c383561c9a97 /cpp/src/qpid/broker/SessionHandler.cpp | |
parent | ff6f9f47dbbaaf84dde2a86dd8f854fcf3060378 (diff) | |
download | qpid-python-7990138bb3eb014c85bfb806c91e23def530ef37.tar.gz |
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
Diffstat (limited to 'cpp/src/qpid/broker/SessionHandler.cpp')
-rw-r--r-- | cpp/src/qpid/broker/SessionHandler.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
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<Semaphore> 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<Semaphore> s(suspension); + if (session.get() && session->isAttached()) { session->detach(); connection.broker.getSessionManager().suspend(session); } |