]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
MonClient: start SafeTimer in MonClient::init()
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 4 Nov 2010 05:00:31 +0000 (22:00 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 4 Nov 2010 05:00:31 +0000 (22:00 -0700)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/mon/MonClient.cc
src/mon/MonClient.h

index ca4d068511aa61a7233001a7396ea8b5db67ac9c..d320b3b55cb9a1cbe8403d2675bc0f13a715d3a8 100644 (file)
@@ -279,6 +279,7 @@ void MonClient::handle_monmap(MMonMap *m)
 void MonClient::init()
 {
   dout(10) << "init" << dendl;
+  timer.reset(new SafeTimer(monc_lock));
   messenger->add_dispatcher_head(this);
 
   entity_name = *g_conf.entity_name;
@@ -308,7 +309,7 @@ void MonClient::init()
 
 void MonClient::shutdown()
 {
-  timer.cancel_all_events();
+  timer->cancel_all_events();
 }
 
 int MonClient::authenticate(double timeout)
@@ -514,9 +515,9 @@ void MonClient::tick()
 void MonClient::schedule_tick()
 {
   if (hunting)
-    timer.add_event_after(g_conf.mon_client_hunt_interval, new C_Tick(this));
+    timer->add_event_after(g_conf.mon_client_hunt_interval, new C_Tick(this));
   else
-    timer.add_event_after(g_conf.mon_client_ping_interval, new C_Tick(this));
+    timer->add_event_after(g_conf.mon_client_ping_interval, new C_Tick(this));
 }
 
 
index cbed179f594bfa13f3588cf57c960aef7ba3d133..ffdde1e5ff4147d0c899e28d86eb78ae31f40456 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "messages/MMonSubscribe.h"
 
+#include <memory>
+
 class MonMap;
 class MMonMap;
 class MMonSubscribeAck;
@@ -56,7 +58,7 @@ private:
   entity_addr_t my_addr;
 
   Mutex monc_lock;
-  SafeTimer timer;
+  std::auto_ptr < SafeTimer > timer;
 
   set<__u32> auth_supported;
 
@@ -163,7 +165,6 @@ public:
     state(MC_STATE_NONE),
     messenger(NULL),
     monc_lock("MonClient::monc_lock"),
-    timer(monc_lock),
     hunting(true),
     want_monmap(true),
     want_keys(0), global_id(0),
@@ -172,7 +173,6 @@ public:
     rotating_secrets(rkeys) { }
 
   ~MonClient() {
-    timer.shutdown();
   }
 
   void init();