qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r827783 - in /qpid/trunk/qpid/cpp/src/qpid/broker: Broker.cpp Broker.h
Date Tue, 20 Oct 2009 20:38:11 GMT
Author: tross
Date: Tue Oct 20 20:38:11 2009
New Revision: 827783

URL: http://svn.apache.org/viewvc?rev=827783&view=rev
Log:
Fixed memory leak on broker shutdown.  Broker's management agent pointer is now
a std::auto_ptr rather than a raw pointer.  The agent pointer was moved in front
of the registries in initialization order to prevent references to deleted management
objects when the registries are destroyed.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=827783&r1=827782&r2=827783&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Tue Oct 20 20:38:11 2009
@@ -140,6 +140,7 @@
     store(0),
     acl(0),
     dataDir(conf.noDataDir ? std::string() : conf.dataDir),
+    managementAgent(conf.enableMgmt ? new ManagementAgent() : 0),
     queues(this),
     exchanges(this),
     links(this),
@@ -150,7 +151,6 @@
             conf.replayFlushLimit*1024, // convert kb to bytes.
             conf.replayHardLimit*1024),
         *this),
-    managementAgent(conf.enableMgmt ? new ManagementAgent() : 0),
     queueCleaner(queues, timer),
     queueEvents(poller,!conf.asyncQueueEvents), 
     recovery(true),
@@ -161,12 +161,12 @@
         QPID_LOG(info, "Management enabled");
         managementAgent->configure(dataDir.isEnabled() ? dataDir.getPath() : string(),
                                    conf.mgmtPubInterval, this, conf.workerThreads + 3);
-        _qmf::Package packageInitializer(managementAgent);
+        _qmf::Package packageInitializer(managementAgent.get());
 
         System* system = new System (dataDir.isEnabled() ? dataDir.getPath() : string(),
this);
         systemObject = System::shared_ptr(system);
 
-        mgmtObject = new _qmf::Broker(managementAgent, this, system, conf.port);
+        mgmtObject = new _qmf::Broker(managementAgent.get(), this, system, conf.port);
         mgmtObject->set_workerThreads(conf.workerThreads);
         mgmtObject->set_maxConns(conf.maxConnections);
         mgmtObject->set_connBacklog(conf.connectionBacklog);
@@ -242,7 +242,7 @@
         Exchange::shared_ptr mExchange = exchanges.get (qpid_management);
         Exchange::shared_ptr dExchange = exchanges.get (amq_direct);
         managementAgent->setExchange(mExchange, dExchange);
-        boost::dynamic_pointer_cast<ManagementExchange>(mExchange)->setManagmentAgent(managementAgent);
+        boost::dynamic_pointer_cast<ManagementExchange>(mExchange)->setManagmentAgent(managementAgent.get());
     }
     else
         QPID_LOG(info, "Management not enabled");

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=827783&r1=827782&r2=827783&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Tue Oct 20 20:38:11 2009
@@ -130,13 +130,13 @@
     AclModule* acl;
     DataDir dataDir;
 
+    std::auto_ptr<management::ManagementAgent> managementAgent;
     QueueRegistry queues;
     ExchangeRegistry exchanges;
     LinkRegistry links;
     boost::shared_ptr<sys::ConnectionCodec::Factory> factory;
     DtxManager dtxManager;
     SessionManager sessionManager;
-    management::ManagementAgent* managementAgent;
     qmf::org::apache::qpid::broker::Broker* mgmtObject;
     Vhost::shared_ptr            vhostObject;
     System::shared_ptr           systemObject;
@@ -237,7 +237,7 @@
     void setRecovery(bool set) { recovery = set; }
     bool getRecovery() const { return recovery; }
 
-    management::ManagementAgent* getManagementAgent() { return managementAgent; }
+    management::ManagementAgent* getManagementAgent() { return managementAgent.get(); }
 };
 
 }}



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message