From c6b37e560d28fc3268ff87047fdcd22e2096aead Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 3 Apr 2007 00:09:00 +0000 Subject: [PATCH] 2161. [bug] 'rndc flush' could report a false success. [RT #16698] --- CHANGES | 2 ++ bin/named/server.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 650bc68cd5..256a4613c0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2161. [bug] 'rndc flush' could report a false success. [RT #16698] + 2156. [bug] Fix node reference leaks in lookup.c:lookup_find(), resolver.c:validated() and resolver.c:cache_name(). Make lookup.c:lookup_find() robust against diff --git a/bin/named/server.c b/bin/named/server.c index 59afab8758..5a50d28665 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.339.2.38 2006/12/07 05:25:03 marka Exp $ */ +/* $Id: server.c,v 1.339.2.39 2007/04/03 00:09:00 marka Exp $ */ #include @@ -3142,7 +3142,8 @@ isc_result_t ns_server_flushcache(ns_server_t *server, char *args) { char *ptr, *viewname; dns_view_t *view; - isc_boolean_t flushed = ISC_FALSE; + isc_boolean_t flushed; + isc_boolean_t found; isc_result_t result; /* Skip the command name. */ @@ -3155,22 +3156,27 @@ ns_server_flushcache(ns_server_t *server, char *args) { result = isc_task_beginexclusive(server->task); RUNTIME_CHECK(result == ISC_R_SUCCESS); + flushed = ISC_TRUE; + found = ISC_FALSE; for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; view = ISC_LIST_NEXT(view, link)) { if (viewname != NULL && strcasecmp(viewname, view->name) != 0) continue; + found = ISC_TRUE; result = dns_view_flushcache(view); if (result != ISC_R_SUCCESS) - goto out; - flushed = ISC_TRUE; + flushed = ISC_FALSE; } - if (flushed) + if (flushed && found) { result = ISC_R_SUCCESS; - else - result = ISC_R_FAILURE; - out: + } else { + if (!found) + result = ISC_R_NOTFOUND; + else + result = ISC_R_FAILURE; + } isc_task_endexclusive(server->task); return (result); }