diff --git a/src/knot/zone/timers.c b/src/knot/zone/timers.c index 69244b5076adc8008d8e9a31c94545a458a853ab..0be92878f7e0dc5e3e395d65a6cb9b3dc78872da 100644 --- a/src/knot/zone/timers.c +++ b/src/knot/zone/timers.c @@ -1,4 +1,4 @@ -/* 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, diff --git a/src/knot/zone/timers.h b/src/knot/zone/timers.h index 9d301dbb973e6f89e30b50adfc27eec00001ea34..df3d491304b7580716b96d9dac1a23edf5d2e466 100644 --- a/src/knot/zone/timers.h +++ b/src/knot/zone/timers.h @@ -1,4 +1,4 @@ -/* 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. diff --git a/src/utils/knotd/main.c b/src/utils/knotd/main.c index 3a75f1ec2e099096d5dc11cba65f6d57b2df25da..da90ef83b886cbf4d3fe877fb6ea3236efc10110 100644 --- a/src/utils/knotd/main.c +++ b/src/utils/knotd/main.c @@ -1,4 +1,4 @@ -/* 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)); } }