]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
timerDB dump: bugfix: proper RCU lock for iterating zoneDB
authorLibor Peltan <libor.peltan@nic.cz>
Sat, 27 Dec 2025 19:36:07 +0000 (20:36 +0100)
committerLibor Peltan <libor.peltan@nic.cz>
Sat, 27 Dec 2025 19:36:07 +0000 (20:36 +0100)
src/knot/server/server.c
src/knot/zone/timers.c

index 68106ce031387a82c88ba92e532689ac323d60e5..e8f8cc52e80d9cac402681606bf04de73bbc2cec 100644 (file)
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <sys/types.h>   // OpenBSD
 #include <sys/resource.h>
+#include <urcu.h>
 
 #include "libknot/libknot.h"
 #include "libknot/yparser/ypschema.h"
@@ -977,7 +978,9 @@ static int timer_db_do_sync(struct dthread *thread)
        server_t *s = thread->data;
 
        while (thread->state & ThreadActive) {
+               rcu_read_lock();
                int ret = zone_timers_write_all(&s->timerdb, s->zone_db);
+               rcu_read_unlock();
                if (ret == KNOT_EOK) {
                        log_info("updated persistent timer DB");
                } else {
index 72f4cdbe9201cba8e187fd7a84e8c162f9e63c04..50dd25808bd0b487b94f7c553ec91e0b0fd11d52 100644 (file)
@@ -8,8 +8,6 @@
 #include "contrib/wire_ctx.h"
 #include "knot/zone/zonedb.h"
 
-#include <urcu.h>
-
 /*
  * # Timer database
  *
@@ -210,10 +208,8 @@ int zone_timers_write(knot_lmdb_db_t *db, const knot_dname_t *zone,
 
 static void txn_zone_write(zone_t *z, knot_lmdb_txn_t *txn)
 {
-       rcu_read_lock();
        zone_timers_t *t = z->timers_static;
        txn_write_timers(txn, z->name, t);
-       rcu_read_unlock();
 }
 
 int zone_timers_write_all(knot_lmdb_db_t *db, knot_zonedb_t *zonedb)