Skip to content
Snippets Groups Projects
Commit 48da8f0f authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

timers: move database from config to server

parent 41187415
No related branches found
No related tags found
1 merge request!294fixes: persistent timers
......@@ -33,7 +33,6 @@
#include "knot/knot.h"
#include "knot/ctl/remote.h"
#include "knot/nameserver/internet.h"
#include "knot/zone/timers.h"
/*
* Defaults.
......@@ -725,10 +724,6 @@ void conf_truncate(conf_t *conf, int unload_hooks)
/* Free remote control iface. */
conf_free_iface(conf->ctl.iface);
/* Close timers db. */
close_timers_db(conf->timers_db);
conf->timers_db = NULL;
}
void conf_free(conf_t *conf)
......@@ -781,13 +776,6 @@ int conf_open(const char* path)
return ret;
}
/* Open zone timers db. */
ret = open_timers_db(nconf->storage, &nconf->timers_db);
if (ret != KNOT_EOK && ret != KNOT_ENOTSUP) {
log_warning("cannot open persistent timers DB (%s)",
knot_strerror(ret));
}
/* Replace current config. */
conf_t **current_config = &s_config;
conf_t *oldconf = rcu_xchg_pointer(current_config, nconf);
......
......@@ -38,7 +38,6 @@
#include "libknot/dnssec/key.h"
#include "libknot/dnssec/policy.h"
#include "common-knot/lists.h"
#include "common/namedb/namedb.h"
#include "common/log.h"
#include "knot/updates/acl.h"
#include "common-knot/sockaddr.h"
......@@ -269,11 +268,6 @@ typedef struct conf_t {
struct query_plan *query_plan;
list_t query_modules;
/*
* Zone timers db
*/
knot_namedb_t *timers_db;
/*
* Remote control interface.
*/
......
......@@ -28,6 +28,7 @@
#include "knot/server/tcp-handler.h"
#include "knot/conf/conf.h"
#include "knot/worker/pool.h"
#include "knot/zone/timers.h"
#include "knot/zone/zonedb-load.h"
#include "libknot/dname.h"
#include "libknot/dnssec/crypto.h"
......@@ -329,6 +330,9 @@ void server_deinit(server_t *server)
/* Free remaining events. */
evsched_deinit(&server->sched);
/* Close persistent timers database. */
close_timers_db(server->timers_db);
/* Clear the structure. */
memset(server, 0, sizeof(server_t));
}
......@@ -578,7 +582,19 @@ int server_reconfigure(const struct conf_t *conf, void *data)
return ret;
}
int server_update_zones(const struct conf_t *conf, void *data)
static void reopen_timers_database(const conf_t *conf, server_t *server)
{
close_timers_db(server->timers_db);
server->timers_db = NULL;
int ret = open_timers_db(conf->storage, &server->timers_db);
if (ret != KNOT_EOK && ret != KNOT_ENOTSUP) {
log_warning("cannot open persistent timers DB (%s)",
knot_strerror(ret));
}
}
int server_update_zones(const conf_t *conf, void *data)
{
server_t *server = (server_t *)data;
......@@ -593,6 +609,7 @@ int server_update_zones(const struct conf_t *conf, void *data)
worker_pool_wait(server->workers);
/* Reload zone database and free old zones. */
reopen_timers_database(conf, server);
int ret = zonedb_reload(conf, server);
/* Trim extra heap. */
......
......@@ -32,6 +32,7 @@
#include "common-knot/evsched.h"
#include "common-knot/lists.h"
#include "common-knot/fdset.h"
#include "common/namedb/namedb.h"
#include "knot/server/dthreads.h"
#include "knot/server/net.h"
#include "knot/server/rrl.h"
......@@ -93,7 +94,9 @@ typedef struct server_t {
/*! \brief Server state tracking. */
volatile unsigned state;
knot_zonedb_t *zone_db; /*!< Zone database. */
/*! \brief Zone database. */
knot_zonedb_t *zone_db;
knot_namedb_t *timers_db;
/*! \brief I/O handlers. */
unsigned tu_size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment