]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/DaemonServer: handle_conf_change - fix broken locking 29213/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 26 Mar 2019 08:08:43 +0000 (16:08 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 23 Jul 2019 12:22:55 +0000 (14:22 +0200)
The is_locked_by_me() is only meant to be safe if you know
you hold the lock. It's meant to be used in an assertion.

Fixes: http://tracker.ceph.com/issues/38899
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit a929a5a01508e661fc7f3cea52822320d39983d2)

Conflicts:
src/mgr/DaemonServer.cc
- leave untouched the mysterious "ohai" log message
- use Mutex::Locker instead of std::lock_guard

src/mgr/DaemonServer.cc

index f67acb3d4e770cfac376e9053557d2375f2655c6..aba28f1f15827c88212f01ef1cf3c92e2b26b045 100644 (file)
@@ -1554,21 +1554,18 @@ void DaemonServer::handle_conf_change(const struct md_config_t *conf,
                                               const std::set <std::string> &changed)
 {
   dout(4) << "ohai" << dendl;
-  // We may be called within lock (via MCommand `config set`) or outwith the
-  // lock (via admin socket `config set`), so handle either case.
-  const bool initially_locked = lock.is_locked_by_me();
-  if (!initially_locked) {
-    lock.Lock();
-  }
 
   if (changed.count("mgr_stats_threshold") || changed.count("mgr_stats_period")) {
     dout(4) << "Updating stats threshold/period on "
             << daemon_connections.size() << " clients" << dendl;
     // Send a fresh MMgrConfigure to all clients, so that they can follow
     // the new policy for transmitting stats
-    for (auto &c : daemon_connections) {
-      _send_configure(c);
-    }
+    finisher.queue(new FunctionContext([this](int r) {
+      Mutex::Locker l(lock);
+      for (auto &c : daemon_connections) {
+        _send_configure(c);
+      }
+    }));
   }
 }