Author: chug Date: Thu Jul 3 13:07:53 2014 New Revision: 1607634 URL: http://svn.apache.org/r1607634 Log: QPID-5869: Check that agent is not null before firing event. Propagate Rajith's logic to the rest of the cases in Acl code.
Modified: qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp Modified: qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp?rev=1607634&r1=1607633&r2=1607634&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp (original) +++ qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp Thu Jul 3 13:07:53 2014 @@ -69,7 +69,7 @@ Acl::Acl (AclValues& av, Broker& b): acl agent = broker->getManagementAgent(); - if (agent != 0){ + if (agent != 0) { _qmf::Package packageInit(agent); mgmtObject = _qmf::Acl::shared_ptr(new _qmf::Acl (agent, this, broker)); agent->addObject (mgmtObject); @@ -100,7 +100,9 @@ void Acl::reportConnectLimit(const std:: if (mgmtObject!=0) mgmtObject->inc_connectionDenyCount(); - agent->raiseEvent(_qmf::EventConnectionDeny(user, addr)); + if (agent != 0) { + agent->raiseEvent(_qmf::EventConnectionDeny(user, addr)); + } } @@ -109,7 +111,9 @@ void Acl::reportQueueLimit(const std::st if (mgmtObject!=0) mgmtObject->inc_queueQuotaDenyCount(); - agent->raiseEvent(_qmf::EventQueueQuotaDeny(user, queueName)); + if (agent != 0) { + agent->raiseEvent(_qmf::EventQueueQuotaDeny(user, queueName)); + } } @@ -208,9 +212,11 @@ bool Acl::result( << " action:" << AclHelper::getActionStr(action) << " ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name ); - agent->raiseEvent(_qmf::EventAllow(id, AclHelper::getActionStr(action), - AclHelper::getObjectTypeStr(objType), - name, types::Variant::Map())); + if (agent != 0) { + agent->raiseEvent(_qmf::EventAllow(id, AclHelper::getActionStr(action), + AclHelper::getObjectTypeStr(objType), + name, types::Variant::Map())); + } // FALLTHROUGH case ALLOW: result = true; @@ -221,9 +227,11 @@ bool Acl::result( << " action:" << AclHelper::getActionStr(action) << " ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name); - agent->raiseEvent(_qmf::EventDeny(id, AclHelper::getActionStr(action), - AclHelper::getObjectTypeStr(objType), - name, types::Variant::Map())); + if (agent != 0) { + agent->raiseEvent(_qmf::EventDeny(id, AclHelper::getActionStr(action), + AclHelper::getObjectTypeStr(objType), + name, types::Variant::Map())); + } // FALLTHROUGH case DENY: if (mgmtObject!=0) @@ -248,7 +256,7 @@ bool Acl::readAclFile(std::string& aclFi boost::shared_ptr<AclData> d(new AclData); AclReader ar(aclValues.aclMaxConnectPerUser, aclValues.aclMaxQueuesPerUser); if (ar.read(aclFile, d)){ - if (agent != 0){ + if (agent != 0) { agent->raiseEvent(_qmf::EventFileLoadFailed("", ar.getError())); } errorText = ar.getError(); @@ -283,7 +291,9 @@ bool Acl::readAclFile(std::string& aclFi mgmtObject->set_transferAcl(transferAcl?1:0); mgmtObject->set_policyFile(aclFile); mgmtObject->set_lastAclLoad(Duration::FromEpoch()); - agent->raiseEvent(_qmf::EventFileLoaded("")); + if (agent != 0) { + agent->raiseEvent(_qmf::EventFileLoaded("")); + } } return true; } @@ -306,7 +316,9 @@ void Acl::loadEmptyAclRuleset() { mgmtObject->set_transferAcl(transferAcl?1:0); mgmtObject->set_policyFile(""); mgmtObject->set_lastAclLoad(Duration::FromEpoch()); - agent->raiseEvent(_qmf::EventFileLoaded("")); + if (agent != 0) { + agent->raiseEvent(_qmf::EventFileLoaded("")); + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org