diff --git a/src/knot/ctl/commands.c b/src/knot/ctl/commands.c index 9baa409ceaa95c610ca19783165936e20c952454..e3b8d70d3ad13f065de4007d0c32feb9beb5ffd0 100644 --- a/src/knot/ctl/commands.c +++ b/src/knot/ctl/commands.c @@ -686,9 +686,7 @@ static int zone_backup_cmd(zone_t *zone, ctl_args_t *args) } if (ret != KNOT_EOK || finish) { - pthread_mutex_lock(&zone->cu_lock); zone->backup_ctx = NULL; - pthread_mutex_unlock(&zone->cu_lock); return ret; } @@ -863,7 +861,8 @@ static int zone_txn_begin_l(zone_t *zone, _unused_ ctl_args_t *args) return KNOT_TXN_EEXISTS; } - if (zone->backup_ctx != NULL && zone->backup_ctx->restore_mode) { + struct zone_backup_ctx *backup_ctx = 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 544fe681fb654da22a50ec24621eb4b6fcafc85b..bbafe7e16019e655298262a10090d8030d2e6a1a 100644 --- a/src/knot/events/handlers/backup.c +++ b/src/knot/events/handlers/backup.c @@ -26,9 +26,7 @@ int event_backup(conf_t *conf, zone_t *zone) { assert(zone); - pthread_mutex_lock(&zone->cu_lock); zone_backup_ctx_t *ctx = zone->backup_ctx; - pthread_mutex_unlock(&zone->cu_lock); if (ctx == NULL) { return KNOT_EINVAL; } @@ -68,8 +66,6 @@ int event_backup(conf_t *conf, zone_t *zone) done: ret_deinit = zone_backup_deinit(ctx); - pthread_mutex_lock(&zone->cu_lock); zone->backup_ctx = NULL; - pthread_mutex_unlock(&zone->cu_lock); return (ret != KNOT_EOK) ? ret : ret_deinit; } diff --git a/src/knot/zone/backup.c b/src/knot/zone/backup.c index 35e2b9bbfb69385aa38796d5c27e949036231229..5c3038a5064186b7b75a232b5fd1e6766f1414bd 100644 --- a/src/knot/zone/backup.c +++ b/src/knot/zone/backup.c @@ -444,9 +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) { - pthread_mutex_lock(&zone->cu_lock); zone_backup_ctx_t *ctx = zone->backup_ctx; - pthread_mutex_unlock(&zone->cu_lock); if (ctx == NULL) { return KNOT_EINVAL; } diff --git a/src/knot/zone/zone.h b/src/knot/zone/zone.h index 61d298a9c5936142dc6c977bf3a90ebe369f5526..a6046de5470e09925f856f18505d1ac4c7d5f9d5 100644 --- a/src/knot/zone/zone.h +++ b/src/knot/zone/zone.h @@ -16,6 +16,7 @@ #pragma once +#include "contrib/atomic.h" #include "contrib/semaphore.h" #include "knot/catalog/catalog_update.h" #include "knot/conf/conf.h" @@ -123,7 +124,7 @@ typedef struct zone struct server *server; /*! \brief Zone backup context (NULL unless backup pending). */ - struct zone_backup_ctx *backup_ctx; + knot_atomic_ptr_t backup_ctx; /*! \brief Catalog-generate feature. */ knot_dname_t *catalog_gen;