]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix leak of health_monitor and config_key_service 334/head
authorSage Weil <sage@inktank.com>
Thu, 30 May 2013 18:07:06 +0000 (11:07 -0700)
committerSage Weil <sage@inktank.com>
Thu, 30 May 2013 18:17:04 +0000 (11:17 -0700)
Switch to using regular pointers here.  The lifecycle of these services is
very simple such that refcounting is overkill.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/ConfigKeyService.cc
src/mon/ConfigKeyService.h
src/mon/DataHealthService.h
src/mon/HealthMonitor.cc
src/mon/HealthMonitor.h
src/mon/HealthService.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/QuorumService.h
src/vstart.sh

index 3319d9e80a83b7c9a56718a9665bd4393500b62f..10c16834c757bc33373f7e020912d41198f383d1 100644 (file)
@@ -16,9 +16,6 @@
 #include <stdlib.h>
 #include <limits.h>
 
-#include <boost/intrusive_ptr.hpp>
-#include "include/assert.h"
-
 #include "mon/Monitor.h"
 #include "mon/QuorumService.h"
 #include "mon/ConfigKeyService.h"
index 49e15acdfc652c25f2ada19227b79e446615ea55..e379af610b9cb96016dddbdee702764ed69a52f9 100644 (file)
@@ -14,9 +14,6 @@
 #ifndef CEPH_MON_CONFIG_KEY_SERVICE_H
 #define CEPH_MON_CONFIG_KEY_SERVICE_H
 
-#include <boost/intrusive_ptr.hpp>
-#include "include/assert.h"
-
 #include "mon/Monitor.h"
 #include "mon/QuorumService.h"
 
@@ -48,9 +45,6 @@ public:
     paxos(p)
   { }
   virtual ~ConfigKeyService() { }
-  ConfigKeyService *get() {
-    return static_cast<ConfigKeyService *>(RefCountedObject::get());
-  }
 
 
   /**
@@ -82,6 +76,5 @@ public:
    * @} // ConfigKeyService_Inherited_h
    */
 };
-typedef boost::intrusive_ptr<ConfigKeyService> ConfigKeyServiceRef;
 
 #endif // CEPH_MON_CONFIG_KEY_SERVICE_H
index c94327f31294260282cdf6b2f144a7749a342262..a17171509c173697e0bee9e8e453f3c04daf3c46 100644 (file)
@@ -14,9 +14,6 @@
 #ifndef CEPH_MON_DATA_HEALTH_SERVICE_H
 #define CEPH_MON_DATA_HEALTH_SERVICE_H
 
-#include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
 #include <errno.h>
 
 #include "include/types.h"
@@ -66,9 +63,6 @@ public:
     set_update_period(g_conf->mon_health_data_update_interval);
   }
   virtual ~DataHealthService() { }
-  DataHealthService *get() {
-    return static_cast<DataHealthService *>(RefCountedObject::get());
-  }
 
   virtual void init() {
     generic_dout(20) << "data_health " << __func__ << dendl;
@@ -86,6 +80,5 @@ public:
     return "data_health";
   }
 };
-typedef boost::intrusive_ptr<DataHealthService> DataHealthServiceRef;
 
 #endif /* CEPH_MON_DATA_HEALTH_SERVICE_H */
index 6239d32a873056b7b70399bb87a8671d4b317613..c6ab6f489180b163c718df807e659a10d0d321c9 100644 (file)
@@ -44,11 +44,11 @@ void HealthMonitor::init()
 {
   dout(10) << __func__ << dendl;
   assert(services.empty());
-  services[HealthService::SERVICE_HEALTH_DATA] =
-    HealthServiceRef(new DataHealthService(mon));
+  services[HealthService::SERVICE_HEALTH_DATA] = new DataHealthService(mon);
 
-  for (map<int,HealthServiceRef>::iterator it = services.begin();
-       it != services.end(); ++it) {
+  for (map<int,HealthService*>::iterator it = services.begin();
+       it != services.end();
+       ++it) {
     it->second->init();
   }
 }
@@ -71,9 +71,11 @@ void HealthMonitor::service_shutdown()
 {
   dout(0) << "HealthMonitor::service_shutdown "
           << services.size() << " services" << dendl;
-  for (map<int,HealthServiceRef>::iterator it = services.begin();
-      it != services.end(); ++it) {
+  for (map<int,HealthService*>::iterator it = services.begin();
+      it != services.end();
+       ++it) {
     it->second->shutdown();
+    delete it->second;
   }
   services.clear();
 }
@@ -87,8 +89,9 @@ health_status_t HealthMonitor::get_health(Formatter *f,
     f->open_array_section("health_services");
   }
 
-  for (map<int,HealthServiceRef>::iterator it = services.begin();
-       it != services.end(); ++it) {
+  for (map<int,HealthService*>::iterator it = services.begin();
+       it != services.end();
+       ++it) {
     health_status_t h = it->second->get_health(f, detail);
     if (overall > h)
       overall = h;
index e0255d20081aaeae3968f4b66f93ca49d3c37b73..a1c98a9bb77565338961ba195df4e5dfe2f3b1a8 100644 (file)
 #ifndef CEPH_HEALTH_MONITOR_H
 #define CEPH_HEALTH_MONITOR_H
 
-#include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
-
 #include "mon/Monitor.h"
 #include "mon/QuorumService.h"
 #include "mon/HealthService.h"
 
 class HealthMonitor : public QuorumService
 {
-  map<int,HealthServiceRef> services;
+  map<int,HealthService*> services;
 
 protected:
   virtual void service_shutdown();
 
 public:
   HealthMonitor(Monitor *m) : QuorumService(m) { }
-  virtual ~HealthMonitor() { }
-  HealthMonitor *get() {
-    return static_cast<HealthMonitor *>(RefCountedObject::get());
+  virtual ~HealthMonitor() {
+    assert(services.empty());
   }
 
 
@@ -52,7 +47,7 @@ public:
   virtual bool service_dispatch(Message *m);
 
   virtual void start_epoch() {
-    for (map<int,HealthServiceRef>::iterator it = services.begin();
+    for (map<int,HealthService*>::iterator it = services.begin();
          it != services.end(); ++it) {
       it->second->start(get_epoch());
     }
@@ -60,9 +55,9 @@ public:
 
   virtual void finish_epoch() {
     generic_dout(20) << "HealthMonitor::finish_epoch()" << dendl;
-    for (map<int,HealthServiceRef>::iterator it = services.begin();
+    for (map<int,HealthService*>::iterator it = services.begin();
          it != services.end(); ++it) {
-      assert(it->second.get() != NULL);
+      assert(it->second != NULL);
       it->second->finish();
     }
   }
@@ -82,6 +77,5 @@ public:
    * @} // HealthMonitor_Inherited_h
    */
 };
-typedef boost::intrusive_ptr<HealthMonitor> HealthMonitorRef;
 
 #endif // CEPH_HEALTH_MONITOR_H
index 1e041f5739ebde7dd4b00f529aefaa89891b4fe2..11d6e485758740ecd3e05ce7e42a94887e36d7c9 100644 (file)
 #ifndef CEPH_MON_HEALTH_SERVICE_H
 #define CEPH_MON_HEALTH_SERVICE_H
 
-#include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
-
 #include "mon/Monitor.h"
 #include "mon/QuorumService.h"
 
@@ -41,14 +37,10 @@ struct HealthService : public QuorumService
   virtual bool service_dispatch(MMonHealth *m) = 0;
 
 public:
-  HealthService *get() {
-    return static_cast<HealthService *>(RefCountedObject::get());
-  }
   virtual health_status_t get_health(Formatter *f,
                           list<pair<health_status_t,string> > *detail) = 0;
   virtual int get_type() = 0;
   virtual string get_name() const = 0;
 };
-typedef boost::intrusive_ptr<HealthService> HealthServiceRef;
 
 #endif // CEPH_MON_HEALTH_SERVICE_H
index acfeb65da6726af07fb990db4f10639792ea936c..4196a18a9a54c0d972e30754668dfec4f1e557a7 100644 (file)
@@ -170,8 +170,8 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
   paxos_service[PAXOS_LOG] = new LogMonitor(this, paxos, "logm");
   paxos_service[PAXOS_AUTH] = new AuthMonitor(this, paxos, "auth");
 
-  health_monitor = QuorumServiceRef(new HealthMonitor(this));
-  config_key_service = ConfigKeyServiceRef(new ConfigKeyService(this, paxos));
+  health_monitor = new HealthMonitor(this);
+  config_key_service = new ConfigKeyService(this, paxos);
 
   mon_caps = new MonCaps();
   mon_caps->set_allow_all(true);
@@ -203,6 +203,8 @@ Monitor::~Monitor()
 {
   for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
     delete *p;
+  delete health_monitor;
+  delete config_key_service;
   delete paxos;
   assert(session_map.sessions.empty());
   delete mon_caps;
index 1443525e9e68ca88e7588175c66a7f44ff12c513..b9203ae1e6150d824d837409e569cbc0503a3c62 100644 (file)
@@ -51,9 +51,6 @@
 #include <memory>
 #include <tr1/memory>
 #include <errno.h>
-#include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
 
 
 #define CEPH_MON_PROTOCOL     10 /* cluster internal */
@@ -1249,8 +1246,8 @@ public:
   friend class PGMonitor;
   friend class LogMonitor;
 
-  boost::intrusive_ptr<QuorumService> health_monitor;
-  boost::intrusive_ptr<QuorumService> config_key_service;
+  QuorumService *health_monitor;
+  QuorumService *config_key_service;
 
   // -- sessions --
   MonSessionMap session_map;
index 16eb8b0542af8f84a02534f6741e40933480dff8..27971b7d599bb93c067eedc3b73515c72f8489e9 100644 (file)
 #ifndef CEPH_MON_QUORUM_SERVICE_H
 #define CEPH_MON_QUORUM_SERVICE_H
 
-#include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
-
 #include <errno.h>
 
 #include "include/types.h"
 
 #include "mon/Monitor.h"
 
-class QuorumService : public RefCountedObject
+class QuorumService
 {
   Context *tick_event;
   double tick_period;
 
   struct C_Tick : public Context {
-    boost::intrusive_ptr<QuorumService> s;
-    C_Tick(boost::intrusive_ptr<QuorumService> qs) : s(qs) { }
+    QuorumService *s;
+    C_Tick(QuorumService *qs) : s(qs) { }
     void finish(int r) {
       if (r < 0)
         return;
@@ -74,8 +70,7 @@ protected:
     if (tick_period <= 0)
       return;
 
-    tick_event = new C_Tick(
-        boost::intrusive_ptr<QuorumService>(this));
+    tick_event = new C_Tick(this);
     mon->timer.add_event_after(tick_period, tick_event);
   }
 
@@ -97,9 +92,6 @@ protected:
 
 public:
   virtual ~QuorumService() { }
-  QuorumService *get() {
-    return static_cast<QuorumService *>(RefCountedObject::get());
-  }
 
   void start(epoch_t new_epoch) {
     epoch = new_epoch;
@@ -138,6 +130,5 @@ public:
   virtual string get_name() const = 0;
 
 };
-typedef boost::intrusive_ptr<QuorumService> QuorumServiceRef;
 
 #endif /* CEPH_MON_QUORUM_SERVICE_H */
index 58411efa4e69c4165112b97597f2f070457a889c..f3717d6535c6eeec560aacb4e4ab5b40ee978c54 100755 (executable)
@@ -182,13 +182,11 @@ if [ "$debug" -eq 0 ]; then
 else
     echo "** going verbose **"
     CMONDEBUG='
-        lockdep = 1
        debug mon = 20
         debug paxos = 20
         debug auth = 20
         debug ms = 1'
     COSDDEBUG='
-        lockdep = 1
         debug ms = 1
         debug osd = 25
         debug monc = 20
@@ -196,7 +194,6 @@ else
         debug filestore = 20
         debug objclass = 20'
     CMDSDEBUG='
-        lockdep = 1
         debug ms = 1
         debug mds = 20
         debug auth = 20