qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject [c++]: race condition in client when handling session close due to execution.exception
Date Fri, 03 Apr 2009 17:53:19 GMT
ConnectionImpl holds weak_ptrs to SessionImpl instances. If all the 
Session objects referring to a given SessionImpl are allowed to go out 
of scope, ConnectionImpl treats the session as having been detached and 
throws a NotAttachedException if there are any incoming frames for the 
channel the session was attached to.

This is particularly problematic when the session is sent an 
execution.exception by the broker. This results in an exception being 
thrown to the application which may well as a result let the session go 
out of scope.

However, following the execution.exception is the session.detach as 
required by the AMQP 0-10 spec. If the session goes out of scope before 
this is handled, then the whole connection ends up being destroyed due 
to the NotAttachedException thrown.

I've raised a jira: https://issues.apache.org/jira/browse/QPID-1785. I 
also have a proposed 'fix' (see patch below). This just prevents the 
NotAttachedException being thrown, logging a message instead.

It does mean that the client would not correctly handle an erroneous 
attempt by the broker to send frames on a session that has genuinely 
been detached. That isn't as serious in my view and seems like a 
worthwhile trade for getting the issue describe in the jira resolved.

Consequently unless there are objections I'll go ahead and apply this patch.

Index: src/qpid/client/ConnectionImpl.cpp
===================================================================
--- src/qpid/client/ConnectionImpl.cpp  (revision 761362)
+++ src/qpid/client/ConnectionImpl.cpp  (working copy)
@@ -111,9 +111,11 @@
          Mutex::ScopedLock l(lock);
          s = sessions[frame.getChannel()].lock();
      }
-    if (!s)
-        throw NotAttachedException(QPID_MSG("Invalid channel: " << 
frame.getChannel()));
-    s->in(frame);
+    if (!s) {
+        QPID_LOG(info, "Dropping frame received on invalid channel: " 
<< frame);
+    } else {
+        s->in(frame);
+    }
  }

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Mime
View raw message