Commit d54b0ba0 authored by Daniel Salzman's avatar Daniel Salzman

server: rework proper config reload

parent 7922962f
......@@ -475,47 +475,47 @@ int server_reload(server_t *server, const char *cf)
return KNOT_EINVAL;
}
if (cf != NULL) {
// Check for no edit mode.
if (conf()->io.txn != NULL) {
log_warning("reload aborted due to active config DB transaction");
return KNOT_CONF_ETXN;
}
// Check for no edit mode.
if (cf != NULL && conf()->io.txn != NULL) {
log_warning("reload aborted due to active config DB transaction");
return KNOT_CONF_ETXN;
}
log_info("reloading configuration file '%s'", cf);
conf_t *new_conf = NULL;
int ret = conf_clone(&new_conf);
if (ret != KNOT_EOK) {
log_error("failed to initialize configuration (%s)",
knot_strerror(ret));
return ret;
}
conf_t *new_conf = NULL;
int ret = conf_clone(&new_conf);
if (ret != KNOT_EOK) {
log_fatal("failed to initialize configuration (%s)",
knot_strerror(ret));
return ret;
}
if (cf != NULL) {
log_info("reloading configuration file '%s'", cf);
/* Import the configuration file. */
ret = conf_import(new_conf, cf, true);
if (ret != KNOT_EOK) {
log_fatal("failed to load configuration file (%s)",
log_error("failed to load configuration file (%s)",
knot_strerror(ret));
conf_free(new_conf);
return ret;
}
/* Run post-open config operations. */
ret = conf_post_open(new_conf);
if (ret != KNOT_EOK) {
log_fatal("failed to use configuration (%s)",
knot_strerror(ret));
conf_free(new_conf);
return ret;
}
/* Update to the new config. */
conf_update(new_conf);
} else {
log_info("reloading configuration database");
}
/* Run post-open config operations. */
ret = conf_post_open(new_conf);
if (ret != KNOT_EOK) {
log_error("failed to use configuration (%s)",
knot_strerror(ret));
conf_free(new_conf);
return ret;
}
/* Update to the new config. */
conf_update(new_conf);
log_reconfigure(conf(), NULL);
server_reconfigure(conf(), server);
server_update_zones(conf(), server);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment