]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
config: more cleanup
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 5 Aug 2011 17:32:42 +0000 (10:32 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 5 Aug 2011 17:32:42 +0000 (10:32 -0700)
* any place where we know a set_val can't fail should be set_val_or_die

* in private md_config_t functions that need the mutex, assert that the
mutex is locked

* make md_config_t::expand_meta private, since nobody uses it outside of
the class.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/common/config.cc
src/common/config.h

index 711614f400421d2d0299407c346c1e5858efe999..e196c3b251d5f09a6ccc3469679f5c45e2a6484a 100644 (file)
@@ -618,22 +618,22 @@ parse_argv(std::vector<const char*>& args)
     // Careful: you can burn through the alphabet pretty quickly by adding
     // to this list.
     else if (ceph_argparse_witharg(args, i, &val, "--monmap", "-M", (char*)NULL)) {
-      set_val("monmap", val.c_str());
+      set_val_or_die("monmap", val.c_str());
     }
     else if (ceph_argparse_witharg(args, i, &val, "--mon_host", "-m", (char*)NULL)) {
-      set_val("mon_host", val.c_str());
+      set_val_or_die("mon_host", val.c_str());
     }
     else if (ceph_argparse_witharg(args, i, &val, "--bind", (char*)NULL)) {
-      set_val("public_addr", val.c_str());
+      set_val_or_die("public_addr", val.c_str());
     }
     else if (ceph_argparse_witharg(args, i, &val, "--keyfile", "-K", (char*)NULL)) {
-      set_val("keyfile", val.c_str());
+      set_val_or_die("keyfile", val.c_str());
     }
     else if (ceph_argparse_witharg(args, i, &val, "--keyring", "-k", (char*)NULL)) {
-      set_val("keyring", val.c_str());
+      set_val_or_die("keyring", val.c_str());
     }
     else if (ceph_argparse_witharg(args, i, &val, "--client_mountpoint", "-r", (char*)NULL)) {
-      set_val("client_mountpoint", val.c_str());
+      set_val_or_die("client_mountpoint", val.c_str());
     }
     else {
       int o;
@@ -948,6 +948,7 @@ set_val_from_default(const config_option *opt)
 int md_config_t::
 set_val_impl(const char *val, const config_option *opt)
 {
+  assert(lock.is_locked());
   int ret = set_val_raw(val, opt);
   if (ret)
     return ret;
@@ -958,6 +959,7 @@ set_val_impl(const char *val, const config_option *opt)
 int md_config_t::
 set_val_raw(const char *val, const config_option *opt)
 {
+  assert(lock.is_locked());
   switch (opt->type) {
     case OPT_INT: {
       std::string err;
@@ -1032,6 +1034,7 @@ static const int NUM_CONF_METAVARIABLES =
 bool md_config_t::
 expand_meta(std::string &val) const
 {
+  assert(lock.is_locked());
   bool found_meta = false;
   string out;
   string::size_type sz = val.size();
index a69d547821977038a3e80ce1d8dc2893f1dce204..4a7b908076d61c1e544ecfa3768a4d8874251f5d 100644 (file)
@@ -133,10 +133,6 @@ public:
   int get_val_from_conf_file(const std::vector <std::string> &sections,
                   const char *key, std::string &out, bool emeta) const;
 
-  // Expand metavariables in the provided string.
-  // Returns true if any metavariables were found and expanded.
-  bool expand_meta(std::string &val) const;
-
 private:
   int parse_config_files_impl(const std::list<std::string> &conf_files,
                   std::deque<std::string> *parse_errors);
@@ -147,6 +143,10 @@ private:
   int set_val_impl(const char *val, const config_option *opt);
   int set_val_raw(const char *val, const config_option *opt);
 
+  // Expand metavariables in the provided string.
+  // Returns true if any metavariables were found and expanded.
+  bool expand_meta(std::string &val) const;
+
   // The configuration file we read, or NULL if we haven't read one.
   ConfFile cf;