Skip to content

Commit

Permalink
fix: prevent coredump in zone-reload by introducing semaphore protect…
Browse files Browse the repository at this point in the history
…ion...

when generating new zone_contents_t for newzone

fixes #939
  • Loading branch information
solidcc2 authored and salzmdan committed Sep 12, 2024
1 parent 252c830 commit 2d20aeb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/knot/zone/zonedb-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ int zone_reload_modules(conf_t *conf, server_t *server, const knot_dname_t *zone
if (newzone == NULL) {
return KNOT_ENOMEM;
}
knot_sem_wait(&newzone->cow_lock);
conf_activate_modules(conf, server, newzone->name, &newzone->query_modules,
&newzone->query_plan);

Expand All @@ -663,6 +664,7 @@ int zone_reload_modules(conf_t *conf, server_t *server, const knot_dname_t *zone
assert(newzone->contents == oldzone->contents);
oldzone->contents = NULL; // contents have been re-used by newzone

knot_sem_post(&newzone->cow_lock);
knot_sem_post(&oldzone->cow_lock);
zone_free(&oldzone);

Expand Down

0 comments on commit 2d20aeb

Please sign in to comment.