]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: fix recursive locking of md_config_t::lock
authorSage Weil <sage.weil@dreamhost.com>
Fri, 16 Mar 2012 20:49:36 +0000 (13:49 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 16 Mar 2012 20:49:36 +0000 (13:49 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
Reviewed-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/common/config.cc
src/common/config.h
src/common/config_obs.h

index e877cde9c170d66e66d8ec48ddd4918949d7af74..f216cdbbd1c92775e27cd066d5f6ae8d197dba76 100644 (file)
@@ -379,6 +379,11 @@ int md_config_t::parse_injectargs(std::vector<const char*>& args,
 void md_config_t::apply_changes(std::ostringstream *oss)
 {
   Mutex::Locker l(lock);
+  _apply_changes(oss);
+}
+
+void md_config_t::_apply_changes(std::ostringstream *oss)
+{
   /* Maps observers to the configuration options that they care about which
    * have changed. */
   typedef std::map < md_config_obs_t*, std::set <std::string> > rev_obs_map_t;
@@ -401,7 +406,7 @@ void md_config_t::apply_changes(std::ostringstream *oss)
   for (changed_set_t::const_iterator c = changed.begin();
        c != changed.end(); ++c) {
     const std::string &key(*c);
-    if ((oss) && (!get_val(key.c_str(), &bufptr, sizeof(buf)))) {
+    if ((oss) && (!_get_val(key.c_str(), &bufptr, sizeof(buf)))) {
       (*oss) << "applying configuration change: " << key << " = '"
                     << buf << "'\n";
     }
@@ -474,7 +479,7 @@ int md_config_t::injectargs(const std::string& s, std::ostringstream *oss)
     *oss << "\n";
     ret = -EINVAL;
   }
-  apply_changes(oss);
+  _apply_changes(oss);
   return ret;
 }
 
@@ -523,6 +528,13 @@ int md_config_t::set_val(const char *key, const char *val)
 int md_config_t::get_val(const char *key, char **buf, int len) const
 {
   Mutex::Locker l(lock);
+  return _get_val(key, buf,len);
+}
+
+int md_config_t::_get_val(const char *key, char **buf, int len) const
+{
+  assert(lock.is_locked());
+
   if (!key)
     return -EINVAL;
 
index 98819be2ae8183811dee1e141e0897483f7700d8..6e5f4e918d643dc3a2db1fdb756a83f79e2e7839 100644 (file)
@@ -109,6 +109,7 @@ public:
 
   // Expand all metavariables. Make any pending observer callbacks.
   void apply_changes(std::ostringstream *oss);
+  void _apply_changes(std::ostringstream *oss);
   void call_all_observers();
 
   // Called by the Ceph daemons to make configuration changes at runtime
@@ -125,6 +126,7 @@ public:
   // Get a configuration value.
   // No metavariables will be returned (they will have already been expanded)
   int get_val(const char *key, char **buf, int len) const;
+  int _get_val(const char *key, char **buf, int len) const;
 
   // Return a list of all the sections that the current entity is a member of.
   void get_my_sections(std::vector <std::string> &sections) const;
index 904ebe339c1a5651783de427475849e3c3705d81..ba2ceacd6e4e0d75d4861f84abb21d243d1de0f4 100644 (file)
@@ -25,7 +25,7 @@ public:
   virtual ~md_config_obs_t();
   virtual const char** get_tracked_conf_keys() const = 0;
   virtual void handle_conf_change(const struct md_config_t *conf,
-                         const std::set <std::string> &changed) = 0;
+                                 const std::set <std::string> &changed) = 0;
 };
 
 #endif