]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: lockless get_instance_id() 993/head
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 5 Dec 2013 07:33:42 +0000 (23:33 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 24 Dec 2013 17:00:11 +0000 (09:00 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/librados/RadosClient.cc
src/librados/RadosClient.h

index 9f63ffb60dd1aed0c03b23dbf11b2069285b1793..06ab0d732f51ffc3544ec57f12dc7dcfa9f8aa50 100644 (file)
@@ -72,6 +72,7 @@ librados::RadosClient::RadosClient(CephContext *cct_)
     state(DISCONNECTED),
     monclient(cct_),
     messenger(NULL),
+    instance_id(0),
     objecter(NULL),
     lock("librados::RadosClient::lock"),
     timer(cct, lock),
@@ -227,6 +228,7 @@ int librados::RadosClient::connect()
   finisher.start();
 
   state = CONNECTED;
+  instance_id = monclient.get_global_id();
 
   lock.Unlock();
 
@@ -255,6 +257,7 @@ void librados::RadosClient::shutdown()
     objecter->shutdown_locked();
   }
   state = DISCONNECTED;
+  instance_id = 0;
   timer.shutdown();   // will drop+retake lock
   lock.Unlock();
   monclient.shutdown();
@@ -269,11 +272,7 @@ void librados::RadosClient::shutdown()
 
 uint64_t librados::RadosClient::get_instance_id()
 {
-  Mutex::Locker l(lock);
-  if (state == DISCONNECTED)
-    return 0;
-  uint64_t id = monclient.get_global_id();
-  return id;
+  return instance_id;
 }
 
 librados::RadosClient::~RadosClient()
index df72bb3405ab6d4593136ecf83018fadeb460565..87860b487d1ca1a86075afbbcbb66210d1c66c5d 100644 (file)
@@ -50,6 +50,8 @@ private:
   MonClient monclient;
   SimpleMessenger *messenger;
 
+  uint64_t instance_id;
+
   bool _dispatch(Message *m);
   bool ms_dispatch(Message *m);