summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-07-03 08:20:06 -0700
committerSage Weil <sage@inktank.com>2012-07-06 16:45:08 -0700
commit01da287b8fdc07262be252f1a7c115734d3cc328 (patch)
tree1b694ef93f537c2a5ec3ac53b301c5d7bf854793
parentc73c64a0f722477a5b0db93da2e26e313a5f52ba (diff)
downloadceph-01da287b8fdc07262be252f1a7c115734d3cc328.tar.gz
config: fix lock recursion in get_val_from_conf_file()
Introduce a private, already-locked version. Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/common/config.cc11
-rw-r--r--src/common/config.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/src/common/config.cc b/src/common/config.cc
index 4dce990cdb9..840ebd2f91c 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<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) {
diff --git a/src/common/config.h b/src/common/config.h
index 52144b8e3b4..212b4dbd621 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 <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);