From eb28d6d9ffe5c18f51a7288f3d536087991c1158 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Mon, 16 Mar 2009 13:08:56 +0100 Subject: Add discard_from_cache(). This function will delete a named entry from cache, if it exists and if caching is turned on. --- cache.c | 19 +++++++++++++++++++ cache.h | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/cache.c b/cache.c index 69d8545..e775cf3 100644 --- a/cache.c +++ b/cache.c @@ -192,3 +192,22 @@ cached_ldap_rdatalist_get(isc_mem_t *mctx, ldap_cache_t *cache, cleanup: return result; } + +isc_result_t +discard_from_cache(ldap_cache_t *cache, dns_name_t *name) +{ + isc_result_t result; + + REQUIRE(cache != NULL); + REQUIRE(name != NULL); + + if (cache->rbt == NULL) + result = ISC_R_SUCCESS; + else + result = dns_rbt_deletename(cache->rbt, name, ISC_FALSE); + + if (result == ISC_R_NOTFOUND) + result = ISC_R_SUCCESS; + + return result; +} diff --git a/cache.h b/cache.h index fcffd49..a8f0558 100644 --- a/cache.h +++ b/cache.h @@ -48,5 +48,11 @@ cached_ldap_rdatalist_get(isc_mem_t *mctx, ldap_cache_t *cache, ldap_db_t *ldap_db, dns_name_t *name, ldapdb_rdatalist_t *rdatalist); +/* + * Discard 'name' from the cache. If caching is not really turned on or 'name' + * is not cached, this function will still return ISC_R_SUCCESS. + */ +isc_result_t +discard_from_cache(ldap_cache_t *cache, dns_name_t *name); #endif /* !_LD_CACHE_H_ */ -- cgit