You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2015/06/10 16:21:54 UTC

svn commit: r1684680 - in /qpid/trunk/qpid/cpp/src/qpid/broker/amqp: Connection.cpp Connection.h Session.cpp Session.h

Author: gsim
Date: Wed Jun 10 14:21:53 2015
New Revision: 1684680

URL: http://svn.apache.org/r1684680
Log:
QPID-6392: handle detach event

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.h

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp?rev=1684680&r1=1684679&r2=1684680&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp Wed Jun 10 14:21:53 2015
@@ -411,6 +411,9 @@ void Connection::process()
         case PN_LINK_REMOTE_OPEN:
             doLinkRemoteOpen(pn_event_link(event));
             break;
+        case PN_LINK_REMOTE_DETACH:
+             doLinkRemoteDetach(pn_event_link(event), false);
+             break;
         case PN_LINK_REMOTE_CLOSE:
             doLinkRemoteClose(pn_event_link(event));
             break;
@@ -579,16 +582,22 @@ void Connection::doLinkRemoteOpen(pn_lin
     }
 }
 
-// the peer has issued a Detach performative
+// the peer has issued a Detach performative with closed=true
 void Connection::doLinkRemoteClose(pn_link_t *link)
 {
+    doLinkRemoteDetach(link, true);
+}
+// the peer has issued a Detach performative
+void Connection::doLinkRemoteDetach(pn_link_t *link, bool closed)
+{
     if ((pn_link_state(link) & PN_LOCAL_CLOSED) == 0) {
-        pn_link_close(link);
+        if (closed) pn_link_close(link);
+        else pn_link_detach(link);
         Sessions::iterator session = sessions.find(pn_link_session(link));
         if (session == sessions.end()) {
             QPID_LOG(error, id << " peer attempted to detach link on unknown session!");
         } else {
-            session->second->detach(link);
+            session->second->detach(link, closed);
             QPID_LOG_CAT(debug, model, id << " link detached");
         }
     }

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h?rev=1684680&r1=1684679&r2=1684680&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h Wed Jun 10 14:21:53 2015
@@ -103,6 +103,7 @@ class Connection : public BrokerContext,
     void doSessionRemoteClose(pn_session_t *session);
     void doLinkRemoteOpen(pn_link_t *link);
     void doLinkRemoteClose(pn_link_t *link);
+    void doLinkRemoteDetach(pn_link_t *link, bool closed);
     void doDeliveryUpdated(pn_delivery_t *delivery);
 };
 }}} // namespace qpid::broker::amqp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.cpp?rev=1684680&r1=1684679&r2=1684680&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.cpp Wed Jun 10 14:21:53 2015
@@ -591,12 +591,12 @@ void Session::attach(pn_link_t* link, co
     }
 }
 
-void Session::detach(pn_link_t* link)
+void Session::detach(pn_link_t* link, bool closed)
 {
     if (pn_link_is_sender(link)) {
         OutgoingLinks::iterator i = outgoing.find(link);
         if (i != outgoing.end()) {
-            i->second->detached(true/*TODO: checked whether actually closed; see PROTON-773*/);
+            i->second->detached(closed);
             boost::shared_ptr<Queue> q = OutgoingFromQueue::getExclusiveSubscriptionQueue(i->second.get());
             if (q && !q->isAutoDelete() && !q->isDeleted()) {
                 connection.getBroker().deleteQueue(q->getName(), connection.getUserId(), connection.getMgmtId());
@@ -607,7 +607,7 @@ void Session::detach(pn_link_t* link)
     } else {
         IncomingLinks::iterator i = incoming.find(link);
         if (i != incoming.end()) {
-            i->second->detached(true/*TODO: checked whether actually closed; see PROTON-773*/);
+            i->second->detached(closed);
             incoming.erase(i);
             QPID_LOG(debug, "Incoming link detached");
         }

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.h?rev=1684680&r1=1684679&r2=1684680&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Session.h Wed Jun 10 14:21:53 2015
@@ -65,7 +65,7 @@ class Session : public ManagedSession, p
      * called for links initiated by the peer
      */
     void attach(pn_link_t*);
-    void detach(pn_link_t*);
+    void detach(pn_link_t*, bool closed);
     void readable(pn_link_t*, pn_delivery_t*);
     void writable(pn_link_t*, pn_delivery_t*);
     bool dispatch();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org