From 165df218ea63d83fe661fc403c2a01839a62f853 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 12 Aug 2009 11:12:16 +0000 Subject: QPID-2046: * perform destroy() on the links own io thread, not on that of the management connection issuingthe request * move ACL check such that it only applies to the management operation git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@803449 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/Link.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'cpp/src/qpid/broker/Link.cpp') diff --git a/cpp/src/qpid/broker/Link.cpp b/cpp/src/qpid/broker/Link.cpp index 061e627f47..d2ecb9dd52 100644 --- a/cpp/src/qpid/broker/Link.cpp +++ b/cpp/src/qpid/broker/Link.cpp @@ -174,18 +174,24 @@ void Link::closed (int, std::string text) destroy(); } +void Link::checkClosePermission() +{ + Mutex::ScopedLock mutex(lock); + + AclModule* acl = getBroker()->getAcl(); + std::string userID = getUsername() + "@" + getBroker()->getOptions().realm; + if (acl && !acl->authorise(userID,acl::ACT_DELETE,acl::OBJ_LINK,"")){ + throw NotAllowedException("ACL denied delete link request"); + } +} + + void Link::destroy () { Bridges toDelete; { Mutex::ScopedLock mutex(lock); - AclModule* acl = getBroker()->getAcl(); - std::string userID = getUsername() + "@" + getBroker()->getOptions().realm; - if (acl && !acl->authorise(userID,acl::ACT_DELETE,acl::OBJ_LINK,"")){ - throw NotAllowedException("ACL denied delete link request"); - } - QPID_LOG (info, "Inter-broker link to " << host << ":" << port << " removed by management"); if (connection) connection->close(CLOSE_CODE_CONNECTION_FORCED, "closed by management"); @@ -412,9 +418,14 @@ Manageable::status_t Link::ManagementMethod (uint32_t op, Args& args, string& te switch (op) { case _qmf::Link::METHOD_CLOSE : - closing = true; - if (state != STATE_CONNECTING) - destroy(); + checkClosePermission(); + if (!closing) { + closing = true; + if (state != STATE_CONNECTING && connection) { + //connection can only be closed on the connections own IO processing thread + connection->requestIOProcessing(boost::bind(&Link::destroy, this)); + } + } return Manageable::STATUS_OK; case _qmf::Link::METHOD_BRIDGE : -- cgit v1.2.1