summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-06-24 12:52:44 -0700
committerSage Weil <sage@inktank.com>2013-06-24 16:15:13 -0700
commiteb86eebe1ba42f04b46f7c3e3419b83eb6fe7f9a (patch)
tree73d9a377c05043832c0ed92024bfbfed76d0ea14
parentcad8cf58188272778bcaf88b910a56a3281426ed (diff)
downloadceph-eb86eebe1ba42f04b46f7c3e3419b83eb6fe7f9a.tar.gz
common/pick_addresses: behave even after internal_safe_to_start_threads
ceph-mon recently started using Preforker to working around forking issues. As a result, internal_safe_to_start_threads got set sooner and calls to pick_addresses() which try to set string config values now fail because there are no config observers for them. Work around this by observing the change while we adjust the value. We assume pick_addresses() callers are smart enough to realize that their result will be reflected by cct->_conf and not magically handled elsewhere. Fixes: #5195, #5205 Backport: cuttlefish Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Dan Mick <dan.mick@inktank.com>
-rw-r--r--src/common/pick_address.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc
index 90327666ad5..ff036c61360 100644
--- a/src/common/pick_address.cc
+++ b/src/common/pick_address.cc
@@ -48,6 +48,24 @@ static const struct sockaddr *find_ip_in_subnet_list(CephContext *cct,
return NULL;
}
+// observe this change
+struct Observer : public md_config_obs_t {
+ const char *conf_var;
+ Observer(const char *c) : conf_var(c) {}
+
+ const char** get_tracked_conf_keys() const {
+ static const char *foo[] = {
+ conf_var,
+ NULL
+ };
+ return foo;
+ }
+ void handle_conf_change(const struct md_config_t *conf,
+ const std::set <std::string> &changed) {
+ // do nothing.
+ }
+};
+
static void fill_in_one_address(CephContext *cct,
const struct ifaddrs *ifa,
const string networks,
@@ -75,8 +93,14 @@ static void fill_in_one_address(CephContext *cct,
exit(1);
}
+ Observer obs(conf_var);
+
+ cct->_conf->add_observer(&obs);
+
cct->_conf->set_val_or_die(conf_var, buf);
cct->_conf->apply_changes(NULL);
+
+ cct->_conf->remove_observer(&obs);
}
void pick_addresses(CephContext *cct, int needs)