]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/MonClient: ignore new mon commands while stopping
authorSage Weil <sage@redhat.com>
Fri, 9 Nov 2018 03:28:18 +0000 (21:28 -0600)
committerSage Weil <sage@redhat.com>
Fri, 16 Nov 2018 05:34:07 +0000 (23:34 -0600)
If one thread is stopping and another threads tries to send a new mon
command, just ignore it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonClient.cc
src/mon/MonClient.h

index e78cd9d0420e53dff9e053776853ec74204a580f..5c7168370b419ab7064668eae60db6c8a3b4fa36 100644 (file)
@@ -441,6 +441,7 @@ void MonClient::shutdown()
 {
   ldout(cct, 10) << __func__ << dendl;
   monc_lock.Lock();
+  stopping = true;
   while (!version_requests.empty()) {
     version_requests.begin()->second->context->complete(-ECANCELED);
     ldout(cct, 20) << __func__ << " canceling and discarding version request "
@@ -471,7 +472,7 @@ void MonClient::shutdown()
   }
   monc_lock.Lock();
   timer.shutdown();
-
+  stopping = false;
   monc_lock.Unlock();
 }
 
@@ -1075,6 +1076,10 @@ void MonClient::start_mon_command(const vector<string>& cmd,
                                 Context *onfinish)
 {
   std::lock_guard l(monc_lock);
+  if (!initialized || stopping) {
+    onfinish->complete(-ECANCELED);
+    return;
+  }
   MonCommand *r = new MonCommand(++last_mon_command_tid);
   r->cmd = cmd;
   r->inbl = inbl;
@@ -1106,6 +1111,10 @@ void MonClient::start_mon_command(const string &mon_name,
                                 Context *onfinish)
 {
   std::lock_guard l(monc_lock);
+  if (!initialized || stopping) {
+    onfinish->complete(-ECANCELED);
+    return;
+  }
   MonCommand *r = new MonCommand(++last_mon_command_tid);
   r->target_name = mon_name;
   r->cmd = cmd;
@@ -1124,6 +1133,10 @@ void MonClient::start_mon_command(int rank,
                                 Context *onfinish)
 {
   std::lock_guard l(monc_lock);
+  if (!initialized || stopping) {
+    onfinish->complete(-ECANCELED);
+    return;
+  }
   MonCommand *r = new MonCommand(++last_mon_command_tid);
   r->target_rank = rank;
   r->cmd = cmd;
index 4d0755c1469707f58231a9cc8a2b8166f84bdbac..c981cca687aba2144eecccc2b86e06b66ff0ea03 100644 (file)
@@ -163,6 +163,7 @@ private:
   Finisher finisher;
 
   bool initialized;
+  bool stopping = false;
   bool no_keyring_disabled_cephx;
 
   LogClient *log_client;