]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: pick_addresses: fix bug with observer class that triggered #5205
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 9 Aug 2013 21:48:15 +0000 (14:48 -0700)
committerSage Weil <sage@inktank.com>
Fri, 9 Aug 2013 22:30:33 +0000 (15:30 -0700)
The Observer class we defined to observe conf changes and thus avoid
triggering #5205 (as fixed by eb86eebe1ba42f04b46f7c3e3419b83eb6fe7f9a),
was returning always the same const static array, which would lead us to
always populate the observer's list with an observer for 'public_addr'.

This would of course become a problem when trying to obtain the observer
for 'cluster_add' during md_config_t::set_val() -- thus triggering the
same assert as initially reported on #5205.

Backport: cuttlefish
Fixes: #5205
Signed-off-by: Joao Eduardo Luis <jecluis@gmail.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 7ed6de9dd7aed59f3c5dd93e012cf080bcc36d8a)

src/common/pick_address.cc

index 21e4c2de328d8757756bb0b53e0aaeb647734423..08dbb4d4366d0485e3920fcc31c0e0fae2688e0b 100644 (file)
@@ -50,15 +50,14 @@ static const struct sockaddr *find_ip_in_subnet_list(CephContext *cct,
 
 // observe this change
 struct Observer : public md_config_obs_t {
-  const char *conf_var;
-  Observer(const char *c) : conf_var(c) {}
+  const char *keys[2];
+  Observer(const char *c) {
+    keys[0] = c;
+    keys[1] = NULL;
+  }
 
   const char** get_tracked_conf_keys() const {
-    static const char *foo[] = {
-      conf_var,
-      NULL
-    };
-    return foo;
+    return (const char **)keys;
   }
   void handle_conf_change(const struct md_config_t *conf,
                          const std::set <std::string> &changed) {