]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add initialized flag to client
authorSage Weil <sage@newdream.net>
Thu, 2 Feb 2012 05:12:31 +0000 (21:12 -0800)
committerSage Weil <sage@newdream.net>
Thu, 2 Feb 2012 17:02:17 +0000 (09:02 -0800)
Do not call init() while initialized; do not call shutdown unless
initialized.

Drop incoming messages if not initialized (we are probably racing with
shutdown).

Signed-off-by: Sage Weil <sage@newdream.net>
src/client/Client.cc
src/client/Client.h

index e01b3937de4ade6b6a419db7ba608653c5b697af..adfc59d1740cbb1f6dc1288bdaadea12b1f494a3 100644 (file)
@@ -272,6 +272,8 @@ void Client::dump_cache()
 int Client::init() 
 {
   Mutex::Locker lock(client_lock);
+  assert(!initialized);
+
   timer.init();
 
   objectcacher->start();
@@ -297,6 +299,7 @@ int Client::init()
   logger = plb.create_perf_counters();
   cct->get_perfcounters_collection()->add(logger);
 
+  initialized = true;
   return r;
 }
 
@@ -307,6 +310,8 @@ void Client::shutdown()
   objectcacher->stop();  // outside of client_lock! this does a join.
 
   client_lock.Lock();
+  assert(initialized);
+  initialized = false;
   timer.shutdown();
   objecter->shutdown();
   client_lock.Unlock();
@@ -1463,6 +1468,11 @@ void Client::handle_client_reply(MClientReply *reply)
 bool Client::ms_dispatch(Message *m)
 {
   client_lock.Lock();
+  if (!initialized) {
+    ldout(cct, 10) << "inactive, discarding " << *m << dendl;
+    m->put();
+    return true;
+  }
 
   switch (m->get_type()) {
     // osd
index 1431bbc8a6020bfd85c60aee98c7f59af149950f..b7ef4a92065ca026a39f14be120919cb4ba75631 100644 (file)
@@ -242,6 +242,7 @@ public:
   void handle_client_request_forward(MClientRequestForward *reply);
   void handle_client_reply(MClientReply *reply);
 
+  bool   initialized;
   bool   mounted;
   bool   unmounting;