]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: fix lock recursion in get_val_from_conf_file()
authorSage Weil <sage@inktank.com>
Tue, 3 Jul 2012 15:20:06 +0000 (08:20 -0700)
committerSage Weil <sage@inktank.com>
Fri, 6 Jul 2012 23:45:08 +0000 (16:45 -0700)
Introduce a private, already-locked version.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/config.cc
src/common/config.h

index 4dce990cdb930a20ae0919eed879315ac3fbe8f8..840ebd2f91c92af1d025ddd797feb36ad64af745 100644 (file)
@@ -220,7 +220,7 @@ int md_config_t::parse_config_files_impl(const std::list<std::string> &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<std::string> &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 <std::string> &section
                    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 <std::string> &sections,
+                                        const char *key, std::string &out, bool emeta) const
+{
+  assert(lock.is_locked());
   std::vector <std::string>::const_iterator s = sections.begin();
   std::vector <std::string>::const_iterator s_end = sections.end();
   for (; s != s_end; ++s) {
index 52144b8e3b442b88ecf3a091469962371ed79ab1..212b4dbd62111be103835ac53f04d87789d05bae 100644 (file)
@@ -145,6 +145,9 @@ public:
 private:
   void _show_config(std::ostream& out);
 
+  int _get_val_from_conf_file(const std::vector <std::string> &sections,
+                             const char *key, std::string &out, bool emeta) const;
+
   int parse_option(std::vector<const char*>& args,
                   std::vector<const char*>::iterator& i,
                   std::ostream *oss);