Commit 3abc7bf2 authored by Michał Kępień's avatar Michał Kępień
Browse files

Merge branch 'fix-loadpending-handling' into 'master'

Fix DNS_ZONEFLG_LOADPENDING handling

See merge request !22
parents 883a9485 801dfe8f
Pipeline #140 passed with stage
in 41 minutes and 20 seconds
4892. [bug] named could leak memory when "rndc reload" was invoked
before all zone loading actions triggered by a previous
"rndc reload" command were completed. [RT #47076]
4891. [placeholder] 4891. [placeholder]
   
4890. [func] Remove unused ondestroy callback from libisc. 4890. [func] Remove unused ondestroy callback from libisc.
......
...@@ -2162,39 +2162,25 @@ static void ...@@ -2162,39 +2162,25 @@ static void
zone_asyncload(isc_task_t *task, isc_event_t *event) { zone_asyncload(isc_task_t *task, isc_event_t *event) {
dns_asyncload_t *asl = event->ev_arg; dns_asyncload_t *asl = event->ev_arg;
dns_zone_t *zone = asl->zone; dns_zone_t *zone = asl->zone;
isc_result_t result = ISC_R_SUCCESS; isc_result_t result;
isc_boolean_t load_pending;
UNUSED(task); UNUSED(task);
REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(DNS_ZONE_VALID(zone));
if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0)
result = ISC_R_CANCELED;
isc_event_free(&event); isc_event_free(&event);
if (result == ISC_R_CANCELED)
goto cleanup;
/* Make sure load is still pending */
LOCK_ZONE(zone); LOCK_ZONE(zone);
load_pending = ISC_TF(DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)); result = zone_load(zone, 0, ISC_TRUE);
if (result != DNS_R_CONTINUE) {
if (!load_pending) { DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADPENDING);
UNLOCK_ZONE(zone);
goto cleanup;
} }
zone_load(zone, 0, ISC_TRUE);
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADPENDING);
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
/* Inform the zone table we've finished loading */ /* Inform the zone table we've finished loading */
if (asl->loaded != NULL) if (asl->loaded != NULL)
(asl->loaded)(asl->loaded_arg, zone, task); (asl->loaded)(asl->loaded_arg, zone, task);
cleanup:
isc_mem_put(zone->mctx, asl, sizeof (*asl)); isc_mem_put(zone->mctx, asl, sizeof (*asl));
dns_zone_idetach(&zone); dns_zone_idetach(&zone);
} }
...@@ -2211,8 +2197,11 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) { ...@@ -2211,8 +2197,11 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) {
return (ISC_R_FAILURE); return (ISC_R_FAILURE);
/* If we already have a load pending, stop now */ /* If we already have a load pending, stop now */
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)) LOCK_ZONE(zone);
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)) {
UNLOCK_ZONE(zone);
return (ISC_R_ALREADYRUNNING); return (ISC_R_ALREADYRUNNING);
}
asl = isc_mem_get(zone->mctx, sizeof (*asl)); asl = isc_mem_get(zone->mctx, sizeof (*asl));
if (asl == NULL) if (asl == NULL)
...@@ -2229,7 +2218,6 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) { ...@@ -2229,7 +2218,6 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) {
if (e == NULL) if (e == NULL)
CHECK(ISC_R_NOMEMORY); CHECK(ISC_R_NOMEMORY);
LOCK_ZONE(zone);
zone_iattach(zone, &asl->zone); zone_iattach(zone, &asl->zone);
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_LOADPENDING); DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_LOADPENDING);
isc_task_send(zone->loadtask, &e); isc_task_send(zone->loadtask, &e);
...@@ -2240,6 +2228,7 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) { ...@@ -2240,6 +2228,7 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) {
failure: failure:
if (asl != NULL) if (asl != NULL)
isc_mem_put(zone->mctx, asl, sizeof (*asl)); isc_mem_put(zone->mctx, asl, sizeof (*asl));
UNLOCK_ZONE(zone);
return (result); return (result);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment