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
commit90d71ec93676223538b5a19d3413771f88a8f084 (patch)
tree8df0efcf7e11e7b1fbaa81fac2c2650fbc737b3e
parentcatalog: fix usage of new atomic in code (variable catalog_upd_signal) (diff)
downloadknot-90d71ec93676223538b5a19d3413771f88a8f084.tar.xz
knot-90d71ec93676223538b5a19d3413771f88a8f084.zip
backup: fix usage of new atomic in code (variable backup_ctx)
-rw-r--r--src/knot/ctl/commands.c8
-rw-r--r--src/knot/events/handlers/backup.c4
-rw-r--r--src/knot/zone/backup.c2
-rw-r--r--src/knot/zone/zone.c4
4 files changed, 11 insertions, 7 deletions
diff --git a/src/knot/ctl/commands.c b/src/knot/ctl/commands.c
index 2bc271c7f..8879faa77 100644
--- a/src/knot/ctl/commands.c
+++ b/src/knot/ctl/commands.c
@@ -662,7 +662,7 @@ static int zone_backup_cmd(zone_t *zone, ctl_args_t *args)
int ret = KNOT_EOK;
pthread_mutex_lock(&zone->cu_lock);
- if (zone->backup_ctx != NULL) {
+ if (ATOMIC_GET(zone->backup_ctx) != NULL) {
log_zone_warning(zone->name, "backup or restore already in progress, skipping zone");
ctx->failed = true;
ret = KNOT_EPROGRESS;
@@ -675,7 +675,7 @@ static int zone_backup_cmd(zone_t *zone, ctl_args_t *args)
}
if (ret == KNOT_EOK) {
- zone->backup_ctx = ctx;
+ ATOMIC_SET(zone->backup_ctx, ctx);
}
pthread_mutex_unlock(&zone->cu_lock);
@@ -699,7 +699,7 @@ static int zone_backup_cmd(zone_t *zone, ctl_args_t *args)
}
if (ret != KNOT_EOK || finish) {
- zone->backup_ctx = NULL;
+ ATOMIC_SET(zone->backup_ctx, NULL);
return ret;
}
@@ -874,7 +874,7 @@ static int zone_txn_begin_l(zone_t *zone, _unused_ ctl_args_t *args)
return KNOT_TXN_EEXISTS;
}
- struct zone_backup_ctx *backup_ctx = zone->backup_ctx;
+ struct zone_backup_ctx *backup_ctx = ATOMIC_GET(zone->backup_ctx);
if (backup_ctx != NULL && backup_ctx->restore_mode) {
log_zone_warning(zone->name, "zone restore pending, try opening control transaction later");
return KNOT_EAGAIN;
diff --git a/src/knot/events/handlers/backup.c b/src/knot/events/handlers/backup.c
index bbafe7e16..f267ea49a 100644
--- a/src/knot/events/handlers/backup.c
+++ b/src/knot/events/handlers/backup.c
@@ -26,7 +26,7 @@ int event_backup(conf_t *conf, zone_t *zone)
{
assert(zone);
- zone_backup_ctx_t *ctx = zone->backup_ctx;
+ zone_backup_ctx_t *ctx = ATOMIC_GET(zone->backup_ctx);
if (ctx == NULL) {
return KNOT_EINVAL;
}
@@ -66,6 +66,6 @@ int event_backup(conf_t *conf, zone_t *zone)
done:
ret_deinit = zone_backup_deinit(ctx);
- zone->backup_ctx = NULL;
+ ATOMIC_SET(zone->backup_ctx, NULL);
return (ret != KNOT_EOK) ? ret : ret_deinit;
}
diff --git a/src/knot/zone/backup.c b/src/knot/zone/backup.c
index 5c3038a50..5bf9b5903 100644
--- a/src/knot/zone/backup.c
+++ b/src/knot/zone/backup.c
@@ -444,7 +444,7 @@ static int backup_kaspdb(zone_backup_ctx_t *ctx, conf_t *conf, zone_t *zone,
int zone_backup(conf_t *conf, zone_t *zone)
{
- zone_backup_ctx_t *ctx = zone->backup_ctx;
+ zone_backup_ctx_t *ctx = ATOMIC_GET(zone->backup_ctx);
if (ctx == NULL) {
return KNOT_EINVAL;
}
diff --git a/src/knot/zone/zone.c b/src/knot/zone/zone.c
index 1302dc9a5..16f645968 100644
--- a/src/knot/zone/zone.c
+++ b/src/knot/zone/zone.c
@@ -194,6 +194,8 @@ zone_t* zone_new(const knot_dname_t *name)
init_list(&zone->internal_notify);
+ ATOMIC_INIT(zone->backup_ctx, NULL);
+
return zone;
}
@@ -243,6 +245,8 @@ void zone_free(zone_t **zone_ptr)
ptrlist_free(&zone->internal_notify, NULL);
+ ATOMIC_DEINIT(zone->backup_ctx);
+
free(zone);
*zone_ptr = NULL;
}