From a3e82e99dd20cee17fec060e7e0b407714426564 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 8 Nov 2018 21:28:18 -0600 Subject: [PATCH] mon/MonClient: ignore new mon commands while stopping If one thread is stopping and another threads tries to send a new mon command, just ignore it. Signed-off-by: Sage Weil --- src/mon/MonClient.cc | 15 ++++++++++++++- src/mon/MonClient.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index e78cd9d0420..5c7168370b4 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -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& 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; diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 4d0755c1469..c981cca687a 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -163,6 +163,7 @@ private: Finisher finisher; bool initialized; + bool stopping = false; bool no_keyring_disabled_cephx; LogClient *log_client; -- 2.39.5