diff --git a/bin/tests/adb_test.c b/bin/tests/adb_test.c index 28b2489a62..044911ffb7 100644 --- a/bin/tests/adb_test.c +++ b/bin/tests/adb_test.c @@ -92,6 +92,8 @@ main(int argc, char **argv) dns_view_t *view; dns_adb_t *adb; dns_adbhandle_t *handle; + dns_adbaddrinfo_t *ai; + isc_stdtime_t now; (void)argc; (void)argv; @@ -100,6 +102,9 @@ main(int argc, char **argv) result = isc_app_start(); check_result(result, "isc_app_start()"); + result = isc_stdtime_get(&now); + check_result(result, "isc_stdtime_get()"); + /* * EVERYTHING needs a memory context. */ @@ -194,6 +199,30 @@ main(int argc, char **argv) dns_adb_dump(adb, stderr); dns_adb_dumphandle(adb, handle, stderr); + /* + * Mark one entry as lame, then look this name up again. + */ + + ai = ISC_LIST_HEAD(handle->list); + INSIST(ai != NULL); + ai = ISC_LIST_NEXT(ai, link); + INSIST(ai != NULL); + result = dns_adb_marklame(adb, ai, &name1, now + 10 * 60); + check_result(result, "dns_adb_marklame()"); + + dns_adb_done(adb, &handle); + + /* + * look it up again + */ + result = dns_adb_lookup(adb, t2, lookup_callback, &name1, + &name1, &name1, &handle); + check_result(result, "dns_adb_lookup name1"); + check_result(handle->result, "handle->result"); + + dns_adb_dump(adb, stderr); + dns_adb_dumphandle(adb, handle, stderr); + /* * delete one of the names, and kill the adb */ @@ -201,7 +230,6 @@ main(int argc, char **argv) check_result(result, "dns_adb_deletename name2"); dns_adb_dump(adb, stderr); - dns_adb_dumphandle(adb, handle, stderr); dns_adb_done(adb, &handle); isc_task_detach(&t1); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 082ee6a01a..166616271e 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -60,8 +60,8 @@ /* * Lengths of lists needs to be powers of two. */ -#define DNS_ADBNAMELIST_LENGTH 16 /* how many buckets for names */ -#define DNS_ADBENTRYLIST_LENGTH 16 /* how many buckets for addresses */ +#define DNS_ADBNAMELIST_LENGTH 32 /* how many buckets for names */ +#define DNS_ADBENTRYLIST_LENGTH 32 /* how many buckets for addresses */ #define FREE_ITEMS 16 /* free count for memory pools */ #define FILL_COUNT 8 /* fill count for memory pools */ @@ -1699,9 +1699,11 @@ construct_name(dns_adb_t *adb, dns_adbhandle_t *handle, dns_name_t *name, } isc_result_t -dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone) +dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone, + isc_stdtime_t expire_time) { dns_adbzoneinfo_t *zi; + int bucket; REQUIRE(DNS_ADB_VALID(adb)); REQUIRE(DNS_ADBADDRINFO_VALID(addr)); @@ -1711,5 +1713,13 @@ dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone) if (zi == NULL) return (ISC_R_NOMEMORY); + zi->lame_timer = expire_time; + + bucket = addr->entry->lock_bucket; + + LOCK(&adb->entrylocks[bucket]); + ISC_LIST_PREPEND(addr->entry->zoneinfo, zi, link); + UNLOCK(&adb->entrylocks[bucket]); + return (ISC_R_SUCCESS); } diff --git a/lib/dns/include/dns/adb.h b/lib/dns/include/dns/adb.h index 1b758bd9ca..c0503fa12b 100644 --- a/lib/dns/include/dns/adb.h +++ b/lib/dns/include/dns/adb.h @@ -366,9 +366,12 @@ dns_adb_dumphandle(dns_adb_t *adb, dns_adbhandle_t *handle, FILE *f); */ isc_result_t -dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone); +dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone, + isc_stdtime_t expire_time); /* - * Mark the given address as lame for the zone "zone". + * Mark the given address as lame for the zone "zone". expire_time should + * be set to the time when the entry should expire. That is, if it is to + * expire 10 minutes in the future, it should set it to (now + 10 * 60). * * Requires: * @@ -392,8 +395,6 @@ dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone); * * Adjust the goodness, both local and globally. * - * Mark an entry as lame. - * * set/clear various flags. (Which flags?) * * Mix in measured RTT values.