From ad61bbd19e299500669ca660b3eb85718716e693 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 3 Jul 2012 08:20:06 -0700 Subject: [PATCH] config: fix lock recursion in get_val_from_conf_file() Introduce a private, already-locked version. Signed-off-by: Sage Weil --- src/common/config.cc | 11 +++++++++-- src/common/config.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index 8f22b57df7fbd..8f2c5b9333ed5 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -220,7 +220,7 @@ int md_config_t::parse_config_files_impl(const std::list &conf_file for (int i = 0; i < NUM_CONFIG_OPTIONS; i++) { config_option *opt = &config_optionsp[i]; std::string val; - int ret = get_val_from_conf_file(my_sections, opt->name, val, false); + int ret = _get_val_from_conf_file(my_sections, opt->name, val, false); if (ret == 0) { set_val_impl(val.c_str(), opt); } @@ -231,7 +231,7 @@ int md_config_t::parse_config_files_impl(const std::list &conf_file std::string as_option("debug_"); as_option += subsys.get_name(o); std::string val; - int ret = get_val_from_conf_file(my_sections, as_option.c_str(), val, false); + int ret = _get_val_from_conf_file(my_sections, as_option.c_str(), val, false); if (ret == 0) { int log, gather; int r = sscanf(val.c_str(), "%d/%d", &log, &gather); @@ -759,6 +759,13 @@ int md_config_t::get_val_from_conf_file(const std::vector §ion const char *key, std::string &out, bool emeta) const { Mutex::Locker l(lock); + return _get_val_from_conf_file(sections, key, out, emeta); +} + +int md_config_t::_get_val_from_conf_file(const std::vector §ions, + const char *key, std::string &out, bool emeta) const +{ + assert(lock.is_locked()); std::vector ::const_iterator s = sections.begin(); std::vector ::const_iterator s_end = sections.end(); for (; s != s_end; ++s) { diff --git a/src/common/config.h b/src/common/config.h index 52144b8e3b442..212b4dbd62111 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -145,6 +145,9 @@ public: private: void _show_config(std::ostream& out); + int _get_val_from_conf_file(const std::vector §ions, + const char *key, std::string &out, bool emeta) const; + int parse_option(std::vector& args, std::vector::iterator& i, std::ostream *oss); -- 2.39.5