]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove rpz->db_registered
authorMatthijs Mekking <matthijs@isc.org>
Fri, 8 Feb 2019 15:20:47 +0000 (16:20 +0100)
committerMatthijs Mekking <github@pletterpet.nl>
Fri, 22 Feb 2019 14:23:59 +0000 (15:23 +0100)
As pointed out in !813 db_registered is sort of redundant.  It is
set to `true` only in `dns_zone_rpz_enable_db()` right before the
`dns_rpz_dbupdate_callback()` callback is registered.  It is only
required in that callback and it is the only place that the callback
is registered.  Therefore there is no path that that `REQUIRE` can
fail.

The `db_registered` variable is only set to `false` in
`dns_rpz_new_zone`, so it is not like the variable is unset again
later.

The only other place where `db_registered` is checked is in
`rpz_detach()`.  If `true`, it will call
`dns_db_updatenotify_unregister()`.  However if that happens, the
`db_registered` is not set back to `false` thus this implies that
this may happen multiple times.  If called a second time, most
likely the unregister function will return `ISC_R_NOTFOUND`, but
the return value is not checked anyway.  So it can do without the
`db_registered` check.

lib/dns/include/dns/rpz.h
lib/dns/rpz.c
lib/dns/zone.c

index 0c12da6e9d93cbd871f7b419f8150a069966cc82..e8f5170ca7f59a0db003a5e44af70a9d65fb4c0b 100644 (file)
@@ -144,15 +144,14 @@ struct dns_rpz_zone {
        isc_ht_t         *nodes;        /* entries in zone */
        dns_rpz_zones_t  *rpzs;         /* owner */
        isc_time_t       lastupdated;   /* last time the zone was processed */
-       bool     updatepending; /* there is an update pending/waiting */
-       bool     updaterunning; /* there is an update running */
+       bool             updatepending; /* there is an update pending/waiting */
+       bool             updaterunning; /* there is an update running */
        dns_db_t         *db;           /* zones database */
        dns_dbversion_t  *dbversion;    /* version we will be updating to */
        dns_db_t         *updb;         /* zones database we're working on */
        dns_dbversion_t  *updbversion;  /* version we're currently working on */
        dns_dbiterator_t *updbit;       /* iterator to use when updating */
        isc_ht_t         *newnodes;     /* entries in zone being updated */
-       bool     db_registered; /* is the notify event registered? */
        isc_timer_t      *updatetimer;
        isc_event_t      updateevent;
 };
index d7112b01ed5613f1f8da795d3f379527dd83e28f..83f8f7d6c5c094f93f92c83bd6c4c60829639cf7 100644 (file)
@@ -1549,7 +1549,6 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) {
        zone->updbversion = NULL;
        zone->updbit = NULL;
        zone->rpzs = rpzs;
-       zone->db_registered = false;
        ISC_EVENT_INIT(&zone->updateevent, sizeof(zone->updateevent),
                       0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
 
@@ -1584,7 +1583,6 @@ dns_rpz_dbupdate_callback(dns_db_t *db, void *fn_arg) {
        REQUIRE(zone != NULL);
 
        LOCK(&zone->rpzs->maint_lock);
-       REQUIRE(zone->db_registered);
 
        /* New zone came as AXFR */
        if (zone->db != NULL && zone->db != db) {
@@ -2100,10 +2098,8 @@ rpz_detach(dns_rpz_zone_t **rpzp, dns_rpz_zones_t *rpzs) {
                dns_db_closeversion(rpz->db, &rpz->dbversion, false);
        }
        if (rpz->db != NULL) {
-               if (rpz->db_registered) {
-                       dns_db_updatenotify_unregister(
-                               rpz->db, dns_rpz_dbupdate_callback, rpz);
-               }
+               dns_db_updatenotify_unregister(
+                       rpz->db, dns_rpz_dbupdate_callback, rpz);
                dns_db_detach(&rpz->db);
        }
        if (rpz->updaterunning) {
index 457e47b927fd203add4f23a995b6a62851b0752e..28f353a2ea9fa5a60c449939874dae7a08eedb47 100644 (file)
@@ -1786,7 +1786,6 @@ dns_zone_rpz_enable_db(dns_zone_t *zone, dns_db_t *db) {
        if (zone->rpz_num == DNS_RPZ_INVALID_NUM)
                return;
        REQUIRE(zone->rpzs != NULL);
-       zone->rpzs->zones[zone->rpz_num]->db_registered = true;
        result = dns_db_updatenotify_register(db,
                                              dns_rpz_dbupdate_callback,
                                              zone->rpzs->zones[zone->rpz_num]);