From d1f8a3eb605b5a606dfd90bd59affc97d8a2d40b Mon Sep 17 00:00:00 2001 From: Ken Giusti Date: Mon, 11 Apr 2011 19:04:02 +0000 Subject: QPID-3197: prevent async command completer from accessing session's connection when session is detached git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1091167 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/SessionState.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/broker/SessionState.cpp') diff --git a/cpp/src/qpid/broker/SessionState.cpp b/cpp/src/qpid/broker/SessionState.cpp index 18dbf63487..eca1883bd9 100644 --- a/cpp/src/qpid/broker/SessionState.cpp +++ b/cpp/src/qpid/broker/SessionState.cpp @@ -127,6 +127,7 @@ bool SessionState::isLocal(const ConnectionToken* t) const void SessionState::detach() { QPID_LOG(debug, getId() << ": detached on broker."); + asyncCommandCompleter->detached(); disableOutput(); handler = 0; if (mgmtObject != 0) @@ -147,6 +148,7 @@ void SessionState::attach(SessionHandler& h) { mgmtObject->set_connectionRef (h.getConnection().GetManagementObject()->getObjectId()); mgmtObject->set_channelId (h.getChannel()); } + asyncCommandCompleter->attached(); } void SessionState::abort() { @@ -486,7 +488,7 @@ void SessionState::AsyncCommandCompleter::scheduleMsgCompletion(SequenceNumber c { qpid::sys::ScopedLock l(completerLock); - if (session) { + if (session && isAttached) { MessageInfo msg(cmd, requiresAccept, requiresSync); completedMsgs.push_back(msg); if (completedMsgs.size() == 1) { @@ -522,4 +524,22 @@ void SessionState::AsyncCommandCompleter::cancel() session = 0; } + +/** inform the completer that the session has attached, + * allows command completion scheduling from any thread */ +void SessionState::AsyncCommandCompleter::attached() +{ + qpid::sys::ScopedLock l(completerLock); + isAttached = true; +} + + +/** inform the completer that the session has detached, + * disables command completion scheduling from any thread */ +void SessionState::AsyncCommandCompleter::detached() +{ + qpid::sys::ScopedLock l(completerLock); + isAttached = false; +} + }} // namespace qpid::broker -- cgit v1.2.1