Author: gsim
Date: Mon Nov 12 09:52:31 2007
New Revision: 594233

URL: http://svn.apache.org/viewvc?rev=594233&view=rev
Log:
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


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp?rev=594233&r1=594232&r2=594233&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp Mon Nov 
12 09:52:31 2007
@@ -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 @@
 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;
 }
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp?rev=594233&r1=594232&r2=594233&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp Mon Nov 12 
09:52:31 2007
@@ -55,17 +55,18 @@
     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() {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h?rev=594233&r1=594232&r2=594233&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h Mon Nov 12 
09:52:31 2007
@@ -62,9 +62,9 @@
 
     void detach();
     void attach(SessionHandler& handler);
+
     
-    /** @pre isAttached() */
-    SessionHandler& getHandler();
+    SessionHandler* getHandler();
 
     /** @pre isAttached() */
     framing::AMQP_ClientProxy& getProxy();


Reply via email to