From: Sage Weil Date: Fri, 16 Mar 2012 20:49:36 +0000 (-0700) Subject: config: fix recursive locking of md_config_t::lock X-Git-Tag: v0.45~77 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8bcc1b3df01fc9fca82fb7e5ae23972fa308e3e;p=ceph.git config: fix recursive locking of md_config_t::lock Signed-off-by: Sage Weil Reviewed-by: Greg Farnum --- diff --git a/src/common/config.cc b/src/common/config.cc index e877cde9c170..f216cdbbd1c9 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -379,6 +379,11 @@ int md_config_t::parse_injectargs(std::vector& 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 > 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; diff --git a/src/common/config.h b/src/common/config.h index 98819be2ae81..6e5f4e918d64 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -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 §ions) const; diff --git a/src/common/config_obs.h b/src/common/config_obs.h index 904ebe339c1a..ba2ceacd6e4e 100644 --- a/src/common/config_obs.h +++ b/src/common/config_obs.h @@ -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 &changed) = 0; + const std::set &changed) = 0; }; #endif