diff --git a/lib/dns/acache.c b/lib/dns/acache.c index fbd8c91025..4142604398 100644 --- a/lib/dns/acache.c +++ b/lib/dns/acache.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acache.c,v 1.12 2006/04/26 12:03:08 shane Exp $ */ +/* $Id: acache.c,v 1.13 2006/04/26 12:12:45 shane Exp $ */ #include @@ -1247,6 +1247,21 @@ dns_acache_createentry(dns_acache_t *acache, dns_db_t *origdb, REQUIRE(entryp != NULL && *entryp == NULL); REQUIRE(origdb != NULL); + /* + * Should we exceed our memory limit for some reason (for + * example, if the cleaner does not run aggressively enough), + * then we will not create additional entries. + * + * XXX: It might be better to lock the acache->cleaner->lock, + * but locking may be an expensive bottleneck. If we misread + * the value, we will occasionally refuse to create a few + * cache entries, or create a few that we should not. I do not + * expect this to happen often, and it will not have very bad + * effects when it does. So no lock for now. + */ + if (acache->cleaner.overmem) + return (ISC_R_NORESOURCES); + newentry = isc_mem_get(acache->mctx, sizeof(*newentry)); if (newentry == NULL) return (ISC_R_NOMEMORY);