summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/broker')
-rw-r--r--cpp/src/qpid/broker/SessionHandler.cpp17
-rw-r--r--cpp/src/qpid/broker/SessionHandler.h3
2 files changed, 13 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);
}
diff --git a/cpp/src/qpid/broker/SessionHandler.h b/cpp/src/qpid/broker/SessionHandler.h
index 52f64779d4..800b886bbf 100644
--- a/cpp/src/qpid/broker/SessionHandler.h
+++ b/cpp/src/qpid/broker/SessionHandler.h
@@ -27,6 +27,8 @@
#include "qpid/framing/AMQP_ClientProxy.h"
#include "qpid/framing/amqp_types.h"
#include "qpid/framing/ChannelHandler.h"
+#include "qpid/sys/Mutex.h"
+#include "qpid/sys/Semaphore.h"
#include <boost/noncopyable.hpp>
@@ -94,6 +96,7 @@ class SessionHandler : public framing::FrameHandler::InOutHandler,
bool ignoring;
bool resuming;
std::auto_ptr<SessionState> session;
+ sys::Semaphore suspension;
};
}} // namespace qpid::broker