diff options
author | Gordon Sim <gsim@apache.org> | 2015-06-10 14:21:53 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2015-06-10 14:21:53 +0000 |
commit | 5f09dfc1ddb8c9b1f5943f62afec25f13c32815a (patch) | |
tree | 6eb9f6e80b22427dc0c431bbff9e54cf97f911c8 | |
parent | cbe3aeacc616bb8e3140bfa504eea3933525af63 (diff) | |
download | qpid-python-5f09dfc1ddb8c9b1f5943f62afec25f13c32815a.tar.gz |
QPID-6392: handle detach event
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1684680 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Connection.cpp | 15 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Connection.h | 1 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Session.cpp | 6 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/amqp/Session.h | 2 |
4 files changed, 17 insertions, 7 deletions
diff --git a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp index 8e2bc86e51..c1c098923e 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp @@ -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_link_t *link) } } -// 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"); } } diff --git a/qpid/cpp/src/qpid/broker/amqp/Connection.h b/qpid/cpp/src/qpid/broker/amqp/Connection.h index e97d041c03..0d06f18924 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Connection.h +++ b/qpid/cpp/src/qpid/broker/amqp/Connection.h @@ -103,6 +103,7 @@ class Connection : public BrokerContext, public sys::ConnectionCodec, public Man 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 diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.cpp b/qpid/cpp/src/qpid/broker/amqp/Session.cpp index 24da9e0fec..aa4ba03dfd 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Session.cpp @@ -591,12 +591,12 @@ void Session::attach(pn_link_t* link, const std::string& src, const std::string& } } -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"); } diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.h b/qpid/cpp/src/qpid/broker/amqp/Session.h index ea3fb82beb..2537d6ca27 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.h +++ b/qpid/cpp/src/qpid/broker/amqp/Session.h @@ -65,7 +65,7 @@ class Session : public ManagedSession, public boost::enable_shared_from_this<Ses * 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(); |