diff options
| author | Ken Giusti <kgiusti@apache.org> | 2011-04-11 19:04:02 +0000 |
|---|---|---|
| committer | Ken Giusti <kgiusti@apache.org> | 2011-04-11 19:04:02 +0000 |
| commit | d1f8a3eb605b5a606dfd90bd59affc97d8a2d40b (patch) | |
| tree | b56cbd9a0e1c81fcc9d2e93152f3073a18c013ab /cpp/src/qpid/broker/SessionState.cpp | |
| parent | e953a539839b35600091560bcfc92ea8516e9e3e (diff) | |
| download | qpid-python-d1f8a3eb605b5a606dfd90bd59affc97d8a2d40b.tar.gz | |
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
Diffstat (limited to 'cpp/src/qpid/broker/SessionState.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/SessionState.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
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<qpid::sys::Mutex> 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<qpid::sys::Mutex> 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<qpid::sys::Mutex> l(completerLock); + isAttached = false; +} + }} // namespace qpid::broker |
