diff options
Diffstat (limited to 'lib/dns/cache.c')
| -rw-r--r-- | lib/dns/cache.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 098823314980..0b6ddb46f2db 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2011, 2013, 2015 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2011, 2013, 2015, 2016 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1199,10 +1199,16 @@ static isc_result_t cleartree(dns_db_t *db, dns_name_t *name) { isc_result_t result, answer = ISC_R_SUCCESS; dns_dbiterator_t *iter = NULL; - dns_dbnode_t *node = NULL; + dns_dbnode_t *node = NULL, *top = NULL; dns_fixedname_t fnodename; dns_name_t *nodename; + /* + * Create the node if it doesn't exist so dns_dbiterator_seek() + * can find it. We will continue even if this fails. + */ + (void)dns_db_findnode(db, name, ISC_TRUE, &top); + dns_fixedname_init(&fnodename); nodename = dns_fixedname_name(&fnodename); @@ -1211,6 +1217,8 @@ cleartree(dns_db_t *db, dns_name_t *name) { goto cleanup; result = dns_dbiterator_seek(iter, name); + if (result == DNS_R_PARTIALMATCH) + result = dns_dbiterator_next(iter); if (result != ISC_R_SUCCESS) goto cleanup; @@ -1245,6 +1253,8 @@ cleartree(dns_db_t *db, dns_name_t *name) { dns_db_detachnode(db, &node); if (iter != NULL) dns_dbiterator_destroy(&iter); + if (top != NULL) + dns_db_detachnode(db, &top); return (answer); } @@ -1262,7 +1272,7 @@ dns_cache_flushnode(dns_cache_t *cache, dns_name_t *name, dns_dbnode_t *node = NULL; dns_db_t *db = NULL; - if (dns_name_equal(name, dns_rootname)) + if (tree && dns_name_equal(name, dns_rootname)) return (dns_cache_flush(cache)); LOCK(&cache->lock); |
