Commit 9f760827 authored by Lubos Slovak's avatar Lubos Slovak

Added a lot of debug output.

parent ef53e7a6
$TTL 1h ; The default expiration time of a resource record without its own TTL value
$ORIGIN example.com.
@ IN SOA ns.example.com. username.example.com. (
2007120712 ; serial number of this zone file
2007120713 ; serial number of this zone file
10 ; slave refresh (1 day)
30 ; slave retry time in case of a problem (1 day)
4w ; slave expiration time (4 weeks)
......
......@@ -1778,6 +1778,13 @@ void dnslib_zone_deep_free(dnslib_zone_t **zone, int free_rdata_dnames)
if (zone == NULL || *zone == NULL) {
return;
}
DEBUG_DNSLIB_ZONE(
char *name = dnslib_dname_to_str((*zone)->apex->owner);
debug_dnslib_zone("Destroying zone %p, name: %s.\n", *zone, name);
free(name);
);
#ifdef USE_HASH_TABLE
if ((*zone)->table != NULL) {
ck_destroy_table(&(*zone)->table, NULL, 0);
......
......@@ -140,6 +140,8 @@ dnslib_zone_t *dnslib_zonedb_replace_zone(dnslib_zonedb_t *db,
return NULL;
}
debug_dnslib_zonedb("Found zone: %p\n", z);
int ret = skip_remove(db->zones,
(void *)dnslib_node_owner(dnslib_zone_apex(zone)),
NULL, NULL);
......@@ -147,12 +149,15 @@ dnslib_zone_t *dnslib_zonedb_replace_zone(dnslib_zonedb_t *db,
return NULL;
}
debug_dnslib_zonedb("Removed zone, return value: %d\n", ret);
debug_dnslib_zonedb("Old zone: %p\n", z);
ret = skip_insert(db->zones,
(void *)dnslib_node_owner(dnslib_zone_apex(zone)),
(void *)zone, NULL);
debug_dnslib_zonedb("Inserted zone, return value: %d\n", ret);
if (ret != 0) {
// return the removed zone back
skip_insert(db->zones,
......@@ -236,6 +241,23 @@ void dnslib_zonedb_deep_free(dnslib_zonedb_t **db)
const skip_node_t *zn = skip_first((*db)->zones);
dnslib_zone_t *zone = NULL;
DEBUG_DNSLIB_ZONEDB(
int i = 1;
char *name = NULL;
while (zn != NULL) {
debug_dnslib_zonedb("%d. zone: %p, key: %p\n", i, zn->value,
zn->key);
assert(zn->key == ((dnslib_zone_t *)zn->value)->apex->owner);
name = dnslib_dname_to_str((dnslib_dname_t *)zn->key);
debug_dnslib_zonedb(" zone name: %s\n", name);
free(name);
zn = skip_next(zn);
}
zn = skip_first((*db)->zones);
);
while (zn != NULL) {
zone = (dnslib_zone_t *)zn->value;
assert(zone != NULL);
......
......@@ -2949,11 +2949,14 @@ int ns_process_axfrin(ns_nameserver_t *nameserver, ns_xfr_t *xfr)
}
dnslib_zone_dump(xfr->zone, 0);
debug_ns("AXFR finished. Saving to zone file.\n");
// save the zone to the disk
rc = ns_save_zone(nameserver, xfr);
if (rc != KNOT_EOK) {
debug_ns("Freeing created zone: %p.\n", xfr->zone);
dnslib_zone_deep_free(&xfr->zone, 1);
debug_ns("%p.\n", xfr->zone);
return rc;
}
return KNOT_EOK;
......@@ -2966,8 +2969,10 @@ int ns_process_axfrin(ns_nameserver_t *nameserver, ns_xfr_t *xfr)
int ns_switch_zone(ns_nameserver_t *nameserver, dnslib_zone_t *zone)
{
debug_ns("Replacing zone by new one: %p\n", zone);
dnslib_zone_t *old = dnslib_zonedb_replace_zone(nameserver->zone_db,
zone);
debug_ns("Old zone: %p\n", old);
if (old == NULL) {
char *name = dnslib_dname_to_str(
dnslib_node_owner(dnslib_zone_apex(zone)));
......@@ -2976,10 +2981,31 @@ int ns_switch_zone(ns_nameserver_t *nameserver, dnslib_zone_t *zone)
}
// wait for readers to finish
debug_ns("Waiting for readers to finish...\n");
synchronize_rcu();
// destroy the old zone
debug_ns("Freeing old zone: %p\n", old);
dnslib_zone_deep_free(&old, 1);
DEBUG_NS(
debug_ns("Zone db contents:\n");
const skip_node_t *zn = skip_first(nameserver->zone_db->zones);
int i = 1;
char *name = NULL;
while (zn != NULL) {
debug_ns("%d. zone: %p, key: %p\n", i, zn->value,
zn->key);
assert(zn->key == ((dnslib_zone_t *)zn->value)->apex->owner);
name = dnslib_dname_to_str((dnslib_dname_t *)zn->key);
debug_ns(" zone name: %s\n", name);
free(name);
zn = skip_next(zn);
}
);
return KNOT_EOK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment