summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Hák <jan.hak@nic.cz>2024-11-26 12:56:51 +0100
committerDaniel Salzman <daniel.salzman@nic.cz>2024-12-11 17:36:20 +0100
commit213ab15226df6ae698f1aa283624a2bc6c9202cd (patch)
treeaa8b5675227b6799dd5075790e03d9db35225e44
parenttests: fix usage of new atomic in code -- test_atomic.c (diff)
downloadknot-213ab15226df6ae698f1aa283624a2bc6c9202cd.tar.xz
knot-213ab15226df6ae698f1aa283624a2bc6c9202cd.zip
catalog: fix usage of new atomic in code (variable catalog_upd_signal)
-rw-r--r--src/knot/catalog/catalog_update.c2
-rw-r--r--src/knot/server/server.c2
-rw-r--r--src/knot/updates/zone-update.c2
-rw-r--r--src/utils/knotd/main.c4
4 files changed, 6 insertions, 4 deletions
diff --git a/src/knot/catalog/catalog_update.c b/src/knot/catalog/catalog_update.c
index 71b7dbe0f..a4470225b 100644
--- a/src/knot/catalog/catalog_update.c
+++ b/src/knot/catalog/catalog_update.c
@@ -405,7 +405,7 @@ int catalog_zone_purge(server_t *server, conf_t *conf, const knot_dname_t *zone)
int ret = catalog_update_del_all(&server->catalog_upd, &server->catalog, zone, &members);
if (ret == KNOT_EOK && members > 0) {
log_zone_info(zone, "catalog zone purged, %zd member zones deconfigured", members);
- server->catalog_upd_signal = true;
+ ATOMIC_SET(server->catalog_upd_signal, true);
if (kill(getpid(), SIGUSR1) != 0) {
ret = knot_map_errno();
}
diff --git a/src/knot/server/server.c b/src/knot/server/server.c
index 627ebd281..40c873fbd 100644
--- a/src/knot/server/server.c
+++ b/src/knot/server/server.c
@@ -849,6 +849,7 @@ int server_init(server_t *server, int bg_workers)
evsched_deinit(&server->sched);
return ret;
}
+ ATOMIC_INIT(server->catalog_upd_signal, false);
pthread_rwlock_init(&server->ctl_lock, NULL);
@@ -913,6 +914,7 @@ void server_deinit(server_t *server)
catalog_update_clear(&server->catalog_upd);
catalog_update_deinit(&server->catalog_upd);
catalog_deinit(&server->catalog);
+ ATOMIC_DEINIT(server->catalog_upd_signal);
/* Close persistent timers DB. */
knot_lmdb_deinit(&server->timerdb);
diff --git a/src/knot/updates/zone-update.c b/src/knot/updates/zone-update.c
index 45c874ebc..0de40d53b 100644
--- a/src/knot/updates/zone-update.c
+++ b/src/knot/updates/zone-update.c
@@ -773,7 +773,7 @@ static int update_catalog(conf_t *conf, zone_update_t *update)
if (ret == KNOT_EOK) {
log_zone_info(update->zone->name, "enqueued %zd catalog updates", upd_count);
- update->zone->server->catalog_upd_signal = true;
+ ATOMIC_SET(update->zone->server->catalog_upd_signal, true);
if (kill(getpid(), SIGUSR1) != 0) {
ret = knot_map_errno();
}
diff --git a/src/utils/knotd/main.c b/src/utils/knotd/main.c
index 55ac0f419..e96377b33 100644
--- a/src/utils/knotd/main.c
+++ b/src/utils/knotd/main.c
@@ -488,9 +488,9 @@ static void event_loop(server_t *server, const char *socket, bool daemonize,
}
if (sig_req_zones_reload && !sig_req_stop) {
sig_req_zones_reload = false;
- reload_t mode = server->catalog_upd_signal ? RELOAD_CATALOG : RELOAD_ZONES;
+ reload_t mode = ATOMIC_GET(server->catalog_upd_signal) ? RELOAD_CATALOG : RELOAD_ZONES;
pthread_rwlock_wrlock(&server->ctl_lock);
- server->catalog_upd_signal = false;
+ ATOMIC_SET(server->catalog_upd_signal, false);
server_update_zones(conf(), server, mode);
pthread_rwlock_unlock(&server->ctl_lock);
}