diff options
author | Gordon Sim <gsim@apache.org> | 2007-11-12 17:52:31 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-11-12 17:52:31 +0000 |
commit | 82362e02efb289ef0c964b7034ccaa10ca4923a6 (patch) | |
tree | b8fd1e5f94ed55e6fc0004e301827a618a3ab775 | |
parent | dbbfec3dc9e886ae4b505537921faf9d6540acf3 (diff) | |
download | qpid-python-82362e02efb289ef0c964b7034ccaa10ca4923a6.tar.gz |
Change to avoid assertion when delivery is concurrent with session detachment:
* in SessionState::getHandler() doesn't assert and just return pointer
* do assertion internally in SessionState where getHandler was relied
for this before
* in SemanticHandler::deliver() get handler and check it; if null then
dump the message and print an error
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@594233 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/broker/SemanticHandler.cpp | 12 | ||||
-rw-r--r-- | cpp/src/qpid/broker/SessionState.cpp | 11 | ||||
-rw-r--r-- | cpp/src/qpid/broker/SessionState.h | 4 |
3 files changed, 16 insertions, 11 deletions
diff --git a/cpp/src/qpid/broker/SemanticHandler.cpp b/cpp/src/qpid/broker/SemanticHandler.cpp index 69dd1fd67e..d6e13e0a55 100644 --- a/cpp/src/qpid/broker/SemanticHandler.cpp +++ b/cpp/src/qpid/broker/SemanticHandler.cpp @@ -29,6 +29,7 @@ #include "qpid/framing/ExecutionCompleteBody.h" #include "qpid/framing/ExecutionResultBody.h" #include "qpid/framing/ServerInvoker.h" +#include "qpid/log/Statement.h" #include <boost/format.hpp> #include <boost/bind.hpp> @@ -166,10 +167,13 @@ void SemanticHandler::handleContent(AMQFrame& frame) DeliveryId SemanticHandler::deliver(QueuedMessage& msg, DeliveryToken::shared_ptr token) { Mutex::ScopedLock l(outLock); - MessageDelivery::deliver( - msg, session.getHandler().out, - ++outgoing.hwm, token, - session.getConnection().getFrameMax()); + SessionHandler* handler = session.getHandler(); + if (handler) { + uint32_t maxFrameSize = handler->getConnection().getFrameMax(); + MessageDelivery::deliver(msg, handler->out, ++outgoing.hwm, token, maxFrameSize); + } else { + QPID_LOG(error, "Dropping message as session is no longer attached to a channel."); + } return outgoing.hwm; } diff --git a/cpp/src/qpid/broker/SessionState.cpp b/cpp/src/qpid/broker/SessionState.cpp index 45d78c9307..d5b6f5ba8a 100644 --- a/cpp/src/qpid/broker/SessionState.cpp +++ b/cpp/src/qpid/broker/SessionState.cpp @@ -55,17 +55,18 @@ SessionState::~SessionState() { factory.erase(getId()); } -SessionHandler& SessionState::getHandler() { - assert(isAttached()); - return *handler; +SessionHandler* SessionState::getHandler() { + return handler; } AMQP_ClientProxy& SessionState::getProxy() { - return getHandler().getProxy(); + assert(isAttached()); + return getHandler()->getProxy(); } Connection& SessionState::getConnection() { - return getHandler().getConnection(); + assert(isAttached()); + return getHandler()->getConnection(); } void SessionState::detach() { diff --git a/cpp/src/qpid/broker/SessionState.h b/cpp/src/qpid/broker/SessionState.h index eed088af31..d710079cd4 100644 --- a/cpp/src/qpid/broker/SessionState.h +++ b/cpp/src/qpid/broker/SessionState.h @@ -62,9 +62,9 @@ class SessionState : public framing::SessionState, void detach(); void attach(SessionHandler& handler); + - /** @pre isAttached() */ - SessionHandler& getHandler(); + SessionHandler* getHandler(); /** @pre isAttached() */ framing::AMQP_ClientProxy& getProxy(); |