From 3fb144cc7da60cf0d7a8f1bbb684b89e71349e14 Mon Sep 17 00:00:00 2001 From: Ken Giusti Date: Wed, 3 Jun 2015 16:04:07 +0000 Subject: QPID-6563: free sessions and links that have completely closed git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1683379 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/amqp/Connection.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp index 5593f755e5..8e2bc86e51 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp @@ -442,10 +442,14 @@ void Connection::process() processDeliveries(); - for (pn_link_t* l = pn_link_head(connection, REQUIRES_CLOSE); l; l = pn_link_next(l, REQUIRES_CLOSE)) { + for (pn_link_t* l = pn_link_head(connection, REQUIRES_CLOSE), *next = 0; + l; l = next) { + next = pn_link_next(l, REQUIRES_CLOSE); doLinkRemoteClose(l); } - for (pn_session_t* s = pn_session_head(connection, REQUIRES_CLOSE); s; s = pn_session_next(s, REQUIRES_CLOSE)) { + for (pn_session_t* s = pn_session_head(connection, REQUIRES_CLOSE), *next = 0; + s; s = next) { + next = pn_session_next(s, REQUIRES_CLOSE); doSessionRemoteClose(s); } if ((pn_connection_state(connection) & REQUIRES_CLOSE) == REQUIRES_CLOSE) { @@ -537,6 +541,7 @@ void Connection::doSessionRemoteClose(pn_session_t *session) QPID_LOG(error, id << " peer attempted to close unrecognised session"); } } + pn_session_free(session); } // the peer has issued an Attach performative @@ -587,6 +592,7 @@ void Connection::doLinkRemoteClose(pn_link_t *link) QPID_LOG_CAT(debug, model, id << " link detached"); } } + pn_link_free(link); } // the status of the delivery has changed -- cgit v1.2.1