]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: start/stop objectcacher thread in init/shutdown, not constructor
authorSage Weil <sage@newdream.net>
Thu, 1 Jul 2010 17:57:21 +0000 (10:57 -0700)
committerSage Weil <sage@newdream.net>
Thu, 1 Jul 2010 17:57:21 +0000 (10:57 -0700)
src/client/Client.cc
src/osdc/ObjectCacher.h

index 9ff52004bcc0c3f888dda193d28b49c636c2cad7..e2d3e0faf18d07c10c9d08c4f67b6603989e7703 100644 (file)
@@ -161,6 +161,8 @@ Client::Client(Messenger *m, MonClient *mc) : timer(client_lock), client_lock("C
 
 Client::~Client() 
 {
+  assert(!client_lock.is_locked());
+
   tear_down_cache();
 
   if (objectcacher) { 
@@ -255,6 +257,8 @@ void Client::init()
 {
   Mutex::Locker lock(client_lock);
 
+  objectcacher->start();
+
   // ok!
   messenger->add_dispatcher_head(this);
 
@@ -290,7 +294,12 @@ void Client::init()
 void Client::shutdown() 
 {
   dout(1) << "shutdown" << dendl;
+
+  objectcacher->stop();  // outside of client_lock! this does a join.
+
+  client_lock.Lock();
   objecter->shutdown();
+  client_lock.Unlock();
   monclient->shutdown();
   messenger->shutdown();
 }
index 7725b8c4a1be40315c3690f4454d9d262c52945e..5178eab3ef1d992efb79bbf6f027563a8d42f85d 100644 (file)
@@ -518,7 +518,6 @@ class ObjectCacher {
     flusher_stop(false), flusher_thread(this),
     stat_waiter(0),
     stat_clean(0), stat_dirty(0), stat_rx(0), stat_tx(0), stat_missing(0) {
-    flusher_thread.create();
   }
   ~ObjectCacher() {
     // we should be empty.
@@ -526,7 +525,12 @@ class ObjectCacher {
     assert(lru_rest.lru_get_size() == 0);
     assert(lru_dirty.lru_get_size() == 0);
     assert(dirty_bh.empty());
-    
+  }
+
+  void start() {
+    flusher_thread.create();
+  }
+  void stop() {
     assert(flusher_thread.is_started());
     lock.Lock();  // hmm.. watch out for deadlock!
     flusher_stop = true;