From eba235f26ca22c892627281ca1abfbe7eada7a3a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 29 Dec 2011 11:57:55 -0800 Subject: [PATCH] common: trigger all observers on startup Among other things, this makes err-to-stderr and friends initialize properly in the DoutStreamBuf. Signed-off-by: Sage Weil --- src/common/common_init.cc | 2 +- src/common/config.cc | 22 ++++++++++++++++++++++ src/common/config.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/common/common_init.cc b/src/common/common_init.cc index 1d874f0d68035..58bbf6d40e89c 100644 --- a/src/common/common_init.cc +++ b/src/common/common_init.cc @@ -101,7 +101,7 @@ void common_init_finish(CephContext *cct) // Trigger callbacks on any config observers that were waiting for // it to become safe to start threads. cct->_conf->set_val("internal_safe_to_start_threads", "true"); - cct->_conf->apply_changes(NULL); + cct->_conf->call_all_observers(); } void common_destroy_context(CephContext *cct) diff --git a/src/common/config.cc b/src/common/config.cc index 4c2bc0d90188c..e877cde9c170d 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -424,6 +424,28 @@ void md_config_t::apply_changes(std::ostringstream *oss) changed.clear(); } +void md_config_t::call_all_observers() +{ + Mutex::Locker l(lock); + + // Expand all metavariables + for (int i = 0; i < NUM_CONFIG_OPTIONS; i++) { + config_option *opt = config_optionsp + i; + if (opt->type == OPT_STR) { + std::string *str = (std::string *)opt->conf_ptr(this); + expand_meta(*str); + } + } + + std::map > obs; + for (obs_map_t::iterator r = observers.begin(); r != observers.end(); ++r) + obs[r->second].insert(r->first); + for (std::map >::iterator p = obs.begin(); + p != obs.end(); + ++p) + p->first->handle_conf_change(this, p->second); +} + int md_config_t::injectargs(const std::string& s, std::ostringstream *oss) { int ret; diff --git a/src/common/config.h b/src/common/config.h index f0f6c3feb99bb..98819be2ae818 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -109,6 +109,7 @@ public: // Expand all metavariables. Make any pending observer callbacks. void apply_changes(std::ostringstream *oss); + void call_all_observers(); // Called by the Ceph daemons to make configuration changes at runtime int injectargs(const std::string &s, std::ostringstream *oss); -- 2.39.5