You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2011/04/12 21:50:07 UTC
svn commit: r1091560 - in /qpid/branches/0.10/qpid/cpp/src/qpid/broker: ./
SessionState.cpp SessionState.h
Author: kgiusti
Date: Tue Apr 12 19:50:07 2011
New Revision: 1091560
URL: http://svn.apache.org/viewvc?rev=1091560&view=rev
Log:
QPID-3197: prevent threads from scheduling async completions when session is detached.
Modified:
qpid/branches/0.10/qpid/cpp/src/qpid/broker/ (props changed)
qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.cpp
qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.h
Propchange: qpid/branches/0.10/qpid/cpp/src/qpid/broker/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Apr 12 19:50:07 2011
@@ -0,0 +1,6 @@
+/qpid/branches/0.5.x-dev/qpid/cpp/src/qpid/broker:892761,894875
+/qpid/branches/0.6-release-windows-installer/cpp/src/qpid/broker:926803
+/qpid/branches/0.6-release-windows-installer/qpid/cpp/src/qpid/broker:926803,927233
+/qpid/branches/java-network-refactor/qpid/cpp/src/qpid/broker:805429-825319
+/qpid/branches/qpid-2935/qpid/cpp/src/qpid/broker:1061302-1072333
+/qpid/trunk/qpid/cpp/src/qpid/broker:1078075,1078733,1078743,1079385,1079590,1079830,1091167
Modified: qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.cpp?rev=1091560&r1=1091559&r2=1091560&view=diff
==============================================================================
--- qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.cpp (original)
+++ qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.cpp Tue Apr 12 19:50:07 2011
@@ -127,6 +127,7 @@ bool SessionState::isLocal(const Connect
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
mgmtObject->set_connectionRef (h.getConnection().GetManagementObject()->getObjectId());
mgmtObject->set_channelId (h.getChannel());
}
+ asyncCommandCompleter->attached();
}
void SessionState::abort() {
@@ -486,7 +488,7 @@ void SessionState::AsyncCommandCompleter
{
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
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
Modified: qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.h
URL: http://svn.apache.org/viewvc/qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.h?rev=1091560&r1=1091559&r2=1091560&view=diff
==============================================================================
--- qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.h (original)
+++ qpid/branches/0.10/qpid/cpp/src/qpid/broker/SessionState.h Tue Apr 12 19:50:07 2011
@@ -187,6 +187,7 @@ class SessionState : public qpid::Sessio
class AsyncCommandCompleter : public RefCounted {
private:
SessionState *session;
+ bool isAttached;
qpid::sys::Mutex completerLock;
// special-case message.transfer commands for optimization
@@ -205,8 +206,8 @@ class SessionState : public qpid::Sessio
/** for scheduling a run of "completeCommands()" on the IO thread */
static void schedule(boost::intrusive_ptr<AsyncCommandCompleter>);
- public:
- AsyncCommandCompleter(SessionState *s) : session(s) {};
+ public:
+ AsyncCommandCompleter(SessionState *s) : session(s), isAttached(s->isAttached()) {};
~AsyncCommandCompleter() {};
/** schedule the completion of an ingress message.transfer command */
@@ -214,6 +215,8 @@ class SessionState : public qpid::Sessio
bool requiresAccept,
bool requiresSync);
void cancel(); // called by SessionState destructor.
+ void attached(); // called by SessionState on attach()
+ void detached(); // called by SessionState on detach()
};
boost::intrusive_ptr<AsyncCommandCompleter> asyncCommandCompleter;
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org