mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Refactor zone stub, refresh and notify event callbacks
This commit cleanups the way how we handle the revent->result in the stub_callback(), refresh_callback() and notify_done() zone callbacks.
This commit is contained in:
@@ -13598,18 +13598,17 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
|
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
||||||
zone_debuglog(zone, me, 1, "exiting");
|
goto exiting;
|
||||||
exiting = true;
|
|
||||||
goto next_primary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_sockaddr_format(&zone->primaryaddr, primary, sizeof(primary));
|
isc_sockaddr_format(&zone->primaryaddr, primary, sizeof(primary));
|
||||||
isc_sockaddr_format(&zone->sourceaddr, source, sizeof(source));
|
isc_sockaddr_format(&zone->sourceaddr, source, sizeof(source));
|
||||||
|
|
||||||
if (revent->result != ISC_R_SUCCESS) {
|
switch (revent->result) {
|
||||||
if (revent->result == ISC_R_TIMEDOUT &&
|
case ISC_R_SUCCESS:
|
||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS))
|
break;
|
||||||
{
|
case ISC_R_TIMEDOUT:
|
||||||
|
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) {
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOEDNS);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOEDNS);
|
||||||
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
||||||
"refreshing stub: timeout retrying "
|
"refreshing stub: timeout retrying "
|
||||||
@@ -13617,6 +13616,8 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
primary, source);
|
primary, source);
|
||||||
goto same_primary;
|
goto same_primary;
|
||||||
}
|
}
|
||||||
|
/* fallthrough */
|
||||||
|
default:
|
||||||
dns_zonemgr_unreachableadd(zone->zmgr, &zone->primaryaddr,
|
dns_zonemgr_unreachableadd(zone->zmgr, &zone->primaryaddr,
|
||||||
&zone->sourceaddr, &now);
|
&zone->sourceaddr, &now);
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
@@ -13762,6 +13763,10 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
exiting:
|
||||||
|
zone_debuglog(zone, me, 1, "exiting");
|
||||||
|
exiting = true;
|
||||||
|
|
||||||
next_primary:
|
next_primary:
|
||||||
isc_mem_put(zone->mctx, cb_args, sizeof(*cb_args));
|
isc_mem_put(zone->mctx, cb_args, sizeof(*cb_args));
|
||||||
if (stub->version != NULL) {
|
if (stub->version != NULL) {
|
||||||
@@ -13971,9 +13976,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
|
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
||||||
isc_event_free(&event);
|
goto exiting;
|
||||||
dns_request_destroy(&zone->request);
|
|
||||||
goto detach;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -13982,19 +13985,18 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
isc_sockaddr_format(&zone->primaryaddr, primary, sizeof(primary));
|
isc_sockaddr_format(&zone->primaryaddr, primary, sizeof(primary));
|
||||||
isc_sockaddr_format(&zone->sourceaddr, source, sizeof(source));
|
isc_sockaddr_format(&zone->sourceaddr, source, sizeof(source));
|
||||||
|
|
||||||
if (revent->result != ISC_R_SUCCESS) {
|
switch (revent->result) {
|
||||||
if (revent->result == ISC_R_TIMEDOUT &&
|
case ISC_R_SUCCESS:
|
||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS))
|
break;
|
||||||
{
|
case ISC_R_TIMEDOUT:
|
||||||
|
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) {
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOEDNS);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOEDNS);
|
||||||
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
||||||
"refresh: timeout retrying without EDNS "
|
"refresh: timeout retrying without EDNS "
|
||||||
"primary %s (source %s)",
|
"primary %s (source %s)",
|
||||||
primary, source);
|
primary, source);
|
||||||
goto same_primary;
|
goto same_primary;
|
||||||
}
|
} else if (!dns_request_usedtcp(revent->request)) {
|
||||||
if (revent->result == ISC_R_TIMEDOUT &&
|
|
||||||
!dns_request_usedtcp(revent->request)) {
|
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
"refresh: retry limit for "
|
"refresh: retry limit for "
|
||||||
"primary %s exceeded (source %s)",
|
"primary %s exceeded (source %s)",
|
||||||
@@ -14020,13 +14022,15 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
"unreachable (cached)",
|
"unreachable (cached)",
|
||||||
primary, source);
|
primary, source);
|
||||||
}
|
}
|
||||||
} else {
|
goto next_primary;
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
|
default:
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
"refresh: failure trying primary "
|
"refresh: failure trying primary "
|
||||||
"%s (source %s): %s",
|
"%s (source %s): %s",
|
||||||
primary, source,
|
primary, source,
|
||||||
isc_result_totext(revent->result));
|
isc_result_totext(revent->result));
|
||||||
}
|
|
||||||
goto next_primary;
|
goto next_primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14370,6 +14374,11 @@ requeue:
|
|||||||
queue_soa_query(zone);
|
queue_soa_query(zone);
|
||||||
goto detach;
|
goto detach;
|
||||||
|
|
||||||
|
exiting:
|
||||||
|
isc_event_free(&event);
|
||||||
|
dns_request_destroy(&zone->request);
|
||||||
|
goto detach;
|
||||||
|
|
||||||
same_primary:
|
same_primary:
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
dns_message_detach(&msg);
|
dns_message_detach(&msg);
|
||||||
@@ -16257,31 +16266,36 @@ notify_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
dns_message_create(notify->zone->mctx, DNS_MESSAGE_INTENTPARSE,
|
dns_message_create(notify->zone->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
&message);
|
&message);
|
||||||
|
|
||||||
|
if (revent->result != ISC_R_SUCCESS) {
|
||||||
result = revent->result;
|
result = revent->result;
|
||||||
if (result == ISC_R_SUCCESS) {
|
goto fail;
|
||||||
result =
|
}
|
||||||
dns_request_getresponse(revent->request, message,
|
|
||||||
|
result = dns_request_getresponse(revent->request, message,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
if (result == ISC_R_SUCCESS) {
|
|
||||||
result = dns_rcode_totext(message->rcode, &buf);
|
result = dns_rcode_totext(message->rcode, &buf);
|
||||||
}
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
notify_log(notify->zone, ISC_LOG_DEBUG(3),
|
notify_log(notify->zone, ISC_LOG_DEBUG(3),
|
||||||
"notify response from %s: %.*s", addrbuf,
|
"notify response from %s: %.*s", addrbuf,
|
||||||
(int)buf.used, rcode);
|
(int)buf.used, rcode);
|
||||||
} else {
|
|
||||||
notify_log(notify->zone, ISC_LOG_DEBUG(2),
|
|
||||||
"notify to %s failed: %s", addrbuf,
|
|
||||||
isc_result_totext(result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_event_free(&event);
|
goto done;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
notify_log(notify->zone, ISC_LOG_DEBUG(2), "notify to %s failed: %s",
|
||||||
|
addrbuf, isc_result_totext(result));
|
||||||
if (result == ISC_R_TIMEDOUT) {
|
if (result == ISC_R_TIMEDOUT) {
|
||||||
notify_log(notify->zone, ISC_LOG_DEBUG(1),
|
notify_log(notify->zone, ISC_LOG_DEBUG(1),
|
||||||
"notify to %s: retries exceeded", addrbuf);
|
"notify to %s: retries exceeded", addrbuf);
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
notify_destroy(notify, false);
|
notify_destroy(notify, false);
|
||||||
|
isc_event_free(&event);
|
||||||
dns_message_detach(&message);
|
dns_message_detach(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user