]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/DaemonState: fix get_config_defaults locking 24668/head
authorSage Weil <sage@redhat.com>
Wed, 17 Oct 2018 16:45:59 +0000 (11:45 -0500)
committerSage Weil <sage@redhat.com>
Wed, 24 Oct 2018 17:55:52 +0000 (12:55 -0500)
One of the callers didn't take the daemon->lock first; fix it.  Also
rename the method so it's more clear the caller does need to lock.

Fixes: http://tracker.ceph.com/issues/36590
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/DaemonServer.cc
src/mgr/DaemonState.h

index a09f457df89f5e27a758d6fb45a08944b5460615..5071a3ca23e548171cce2e6206d969ca6082936c 100644 (file)
@@ -1589,6 +1589,7 @@ bool DaemonServer::_handle_command(
     key.first = who.substr(0, dot);
     key.second = who.substr(dot + 1);
     DaemonStatePtr daemon = daemon_state.get(key);
+    std::lock_guard l(daemon->lock);
     string name;
     if (!daemon) {
       ss << "no config state for daemon " << who;
@@ -1599,7 +1600,7 @@ bool DaemonServer::_handle_command(
          !p->second.empty()) {
        cmdctx->odata.append(p->second.rbegin()->second + "\n");
       } else {
-       auto& defaults = daemon->get_config_defaults();
+       auto& defaults = daemon->_get_config_defaults();
        auto q = defaults.find(name);
        if (q != defaults.end()) {
          cmdctx->odata.append(q->second + "\n");
@@ -1608,7 +1609,6 @@ bool DaemonServer::_handle_command(
        }
       }
     } else if (daemon->config_defaults_bl.length() > 0) {
-      std::lock_guard l(daemon->lock);
       TextTable tbl;
       if (f) {
        f->open_array_section("config");
@@ -1675,7 +1675,7 @@ bool DaemonServer::_handle_command(
        }
       } else {
        // show-with-defaults
-       auto& defaults = daemon->get_config_defaults();
+       auto& defaults = daemon->_get_config_defaults();
        for (auto& i : defaults) {
          if (f) {
            f->open_object_section("value");
index 9f2456b4590eb6d9d3c6566d9faa95ce1a119e05..42b7ed9b2838fb4afe05ab923affb1f02fe2b622 100644 (file)
@@ -182,7 +182,7 @@ class DaemonState
     }
   }
 
-  const std::map<std::string,std::string>& get_config_defaults() {
+  const std::map<std::string,std::string>& _get_config_defaults() {
     if (config_defaults.empty() &&
        config_defaults_bl.length()) {
       auto p = config_defaults_bl.cbegin();