Skip to content
Snippets Groups Projects
Commit 0bccb34b authored by Daniel Salzman's avatar Daniel Salzman
Browse files

knotd: improve timers writing at shutdown

parent 1a7ebde6
No related branches found
No related tags found
No related merge requests found
Pipeline #
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -201,9 +201,9 @@ int zone_timers_write_begin(knot_db_t *db, knot_db_txn_t *txn)
return knot_db_lmdb_api()->txn_begin(db, txn, KNOT_DB_SORTED);
}
void zone_timers_write_end(knot_db_txn_t *txn)
int zone_timers_write_end(knot_db_txn_t *txn)
{
knot_db_lmdb_api()->txn_commit(txn);
return knot_db_lmdb_api()->txn_commit(txn);
}
int zone_timers_write(knot_db_t *db, const knot_dname_t *zone,
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -81,7 +81,7 @@ int zone_timers_write_begin(knot_db_t *db, knot_db_txn_t *txn);
*
* \return KNOT_E*
*/
void zone_timers_write_end(knot_db_txn_t *txn);
int zone_timers_write_end(knot_db_txn_t *txn);
/*!
* \brief Write timers for one zone.
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -386,13 +386,17 @@ static void write_timers(const zone_t *zone, knot_db_txn_t *txn, int *ret)
static void update_timerdb(server_t *server)
{
log_info("updating zone timers database");
knot_db_txn_t timers_txn;
int timers_ret = zone_timers_write_begin(server->timers_db, &timers_txn);
knot_zonedb_foreach(server->zone_db, write_timers, &timers_txn, &timers_ret);
if (timers_ret == KNOT_EOK) {
zone_timers_write_end(&timers_txn);
} else {
log_warning("updating zone timers database failed (%s)", knot_strerror(timers_ret));
knot_db_txn_t txn;
int ret = zone_timers_write_begin(server->timers_db, &txn);
if (ret == KNOT_EOK) {
knot_zonedb_foreach(server->zone_db, write_timers, &txn, &ret);
}
if (ret == KNOT_EOK) {
ret = zone_timers_write_end(&txn);
}
if (ret != KNOT_EOK) {
log_warning("failed to update zone timers database (%s)", knot_strerror(ret));
}
}
......
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