From 824c3af7e0ff6428fb2d6b1eb51b6813c2421175 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 1 Feb 2012 21:12:31 -0800 Subject: [PATCH] client: add initialized flag to client 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 --- src/client/Client.cc | 10 ++++++++++ src/client/Client.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index e01b3937de4ad..adfc59d1740cb 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 diff --git a/src/client/Client.h b/src/client/Client.h index 1431bbc8a6020..b7ef4a92065ca 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -242,6 +242,7 @@ public: void handle_client_request_forward(MClientRequestForward *reply); void handle_client_reply(MClientReply *reply); + bool initialized; bool mounted; bool unmounting; -- 2.39.5