|
|
4b13ad |
From 6f77c4d846a7b1f798139fb92c9d385545c74a02 Mon Sep 17 00:00:00 2001
|
|
|
4b13ad |
From: Sage Weil <sage@inktank.com>
|
|
|
4b13ad |
Date: Mon, 31 Mar 2014 15:36:26 -0700
|
|
|
4b13ad |
Subject: [PATCH] config: allow unsafe setting of config values
|
|
|
4b13ad |
|
|
|
4b13ad |
Allow callers to set config values even when there is no observer.
|
|
|
4b13ad |
|
|
|
4b13ad |
Signed-off-by: Sage Weil <sage@inktank.com>
|
|
|
4b13ad |
(cherry picked from commit e1418724a0da3979b1e706ccb54112d35c18f1eb)
|
|
|
4b13ad |
---
|
|
|
4b13ad |
src/common/config.cc | 4 ++--
|
|
|
4b13ad |
src/common/config.h | 5 ++++-
|
|
|
4b13ad |
2 files changed, 6 insertions(+), 3 deletions(-)
|
|
|
4b13ad |
|
|
|
4b13ad |
diff --git a/src/common/config.cc b/src/common/config.cc
|
|
|
4b13ad |
index 23bfe35..7952aaf 100644
|
|
|
4b13ad |
--- a/src/common/config.cc
|
|
|
4b13ad |
+++ b/src/common/config.cc
|
|
|
4b13ad |
@@ -659,7 +659,7 @@ void md_config_t::set_val_or_die(const char *key, const char *val)
|
|
|
4b13ad |
assert(ret == 0);
|
|
|
4b13ad |
}
|
|
|
4b13ad |
|
|
|
4b13ad |
-int md_config_t::set_val(const char *key, const char *val, bool meta)
|
|
|
4b13ad |
+int md_config_t::set_val(const char *key, const char *val, bool meta, bool safe)
|
|
|
4b13ad |
{
|
|
|
4b13ad |
Mutex::Locker l(lock);
|
|
|
4b13ad |
if (!key)
|
|
|
4b13ad |
@@ -696,7 +696,7 @@ int md_config_t::set_val(const char *key, const char *val, bool meta)
|
|
|
4b13ad |
for (int i = 0; i < NUM_CONFIG_OPTIONS; ++i) {
|
|
|
4b13ad |
config_option *opt = &config_optionsp[i];
|
|
|
4b13ad |
if (strcmp(opt->name, k.c_str()) == 0) {
|
|
|
4b13ad |
- if (internal_safe_to_start_threads) {
|
|
|
4b13ad |
+ if (safe && internal_safe_to_start_threads) {
|
|
|
4b13ad |
// If threads have been started...
|
|
|
4b13ad |
if ((opt->type == OPT_STR) || (opt->type == OPT_ADDR) ||
|
|
|
4b13ad |
(opt->type == OPT_UUID)) {
|
|
|
4b13ad |
diff --git a/src/common/config.h b/src/common/config.h
|
|
|
4b13ad |
index 242b467..9911543 100644
|
|
|
4b13ad |
--- a/src/common/config.h
|
|
|
4b13ad |
+++ b/src/common/config.h
|
|
|
4b13ad |
@@ -130,7 +130,10 @@ public:
|
|
|
4b13ad |
|
|
|
4b13ad |
// Set a configuration value.
|
|
|
4b13ad |
// Metavariables will be expanded.
|
|
|
4b13ad |
- int set_val(const char *key, const char *val, bool meta=true);
|
|
|
4b13ad |
+ int set_val(const char *key, const char *val, bool meta=true, bool safe=true);
|
|
|
4b13ad |
+ int set_val(const char *key, const string& s, bool meta=true, bool safe=true) {
|
|
|
4b13ad |
+ return set_val(key, s.c_str(), meta, safe);
|
|
|
4b13ad |
+ }
|
|
|
4b13ad |
|
|
|
4b13ad |
// Get a configuration value.
|
|
|
4b13ad |
// No metavariables will be returned (they will have already been expanded)
|
|
|
4b13ad |
--
|
|
|
4b13ad |
1.9.3
|
|
|
4b13ad |
|