dirty = true;
}
+
+/* Fills 'svec' with all of the key-value pairs that have sections that
+ * begin with 'section'. The caller must first initialize 'svec'. */
+void
+cfg_get_section(struct svec *svec, const char *section_, ...)
+{
+ struct ds section;
+ va_list args;
+ char **p;
+
+ ds_init(§ion);
+ va_start(args, section_);
+ ds_put_format_valist(§ion, section_, args);
+ ds_put_char(§ion, '.');
+ va_end(args);
+
+ for (p = cfg.names; *p; p++) { /* XXX this is inefficient */
+ if (!strncmp(section.string, *p, section.length)) {
+ svec_add(svec, *p);
+ }
+ }
+ ds_destroy(§ion);
+}
+
/* Returns the value numbered 'idx' of 'key'. Returns a null pointer if 'idx'
* is greater than or equal to cfg_count(key). The caller must not modify or
* free the returned string or retain its value beyond the next call to
void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
+void cfg_get_section(struct svec *svec, const char *key, ...)
+ PRINTF_FORMAT(2, 3);
bool cfg_has(const char *key, ...) PRINTF_FORMAT(1, 2);
bool cfg_is_valid(enum cfg_flags, const char *key, ...) PRINTF_FORMAT(2, 3);
}
svec_init(&new_cfg);
- cfg_get_subsections(&new_cfg, "mgmt");
+ cfg_get_section(&new_cfg, "mgmt");
if (svec_equal(&mgmt_cfg, &new_cfg)) {
/* Reconnecting to the controller causes the config file to be
* resent automatically. If we're not reconnecting and the
if (cfg_updated && mgmt_rconn) {
send_config_update(0, false);
}
+ svec_destroy(&new_cfg);
return;
}
controller_name = cfg_get_string(0, "mgmt.controller");
if (!controller_name) {
VLOG_ERR("no controller specified for managment");
+ svec_destroy(&new_cfg);
return;
}
mgmt_rconn = NULL;
}
mgmt_rconn = rconn_create(inactivity_probe, max_backoff);
- if (controller_name) {
- retval = rconn_connect(mgmt_rconn, controller_name);
- if (retval == EAFNOSUPPORT) {
- VLOG_ERR("no support for %s vconn", controller_name);
- }
+ retval = rconn_connect(mgmt_rconn, controller_name);
+ if (retval == EAFNOSUPPORT) {
+ VLOG_ERR("no support for %s vconn", controller_name);
}
}