catz: protect db_registered and db callback (un)registration with a lock

Doing this to avoid a race between the 'dns__catz_update_cb()' and
'dns_catz_dbupdate_callback()' functions.
This commit is contained in:
Aram Sargsyan 2023-03-02 10:18:11 +00:00
parent d2ecff3c4a
commit a87859f1fa

View file

@ -2480,6 +2480,7 @@ final:
* update callback in zone_startload or axfr_makedb, but we will
* call onupdate() artificially so we can register the callback here.
*/
LOCK(&catzs->lock);
if (!oldcatz->db_registered) {
result = dns_db_updatenotify_register(
updb, dns_catz_dbupdate_callback, oldcatz->catzs);
@ -2487,6 +2488,7 @@ final:
oldcatz->db_registered = true;
}
}
UNLOCK(&catzs->lock);
exit:
catz->updateresult = result;