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.

(cherry picked from commit a87859f1fa)
This commit is contained in:
Aram Sargsyan 2023-03-02 10:18:11 +00:00
parent 574682b8c7
commit d6001423af

View file

@ -2500,6 +2500,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);
@ -2507,6 +2508,7 @@ final:
oldcatz->db_registered = true;
}
}
UNLOCK(&catzs->lock);
exit:
catz->updateresult = result;