mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
change from isc_nmhandle_ref/unref to isc_nmhandle attach/detach
Attaching and detaching handle pointers will make it easier to determine where and why reference counting errors have occurred. A handle needs to be referenced more than once when multiple asynchronous operations are in flight, so callers must now maintain multiple handle pointers for each pending operation. For example, ns_client objects now contain: - reqhandle: held while waiting for a request callback (query, notify, update) - sendhandle: held while waiting for a send callback - fetchhandle: held while waiting for a recursive fetch to complete - updatehandle: held while waiting for an update-forwarding task to complete control channel connection objects now contain: - readhandle: held while waiting for a read callback - sendhandle: held while waiting for a send callback - cmdhandle: held while an rndc command is running httpd connections contain: - readhandle: held while waiting for a read callback - sendhandle: held while waiting for a send callback
This commit is contained in:
@@ -1567,7 +1567,7 @@ send_update_event(ns_client_t *client, dns_zone_t *zone) {
|
||||
client->nupdates++;
|
||||
event->ev_arg = client;
|
||||
|
||||
isc_nmhandle_ref(client->handle);
|
||||
isc_nmhandle_attach(client->handle, &client->updatehandle);
|
||||
dns_zone_gettask(zone, &zonetask);
|
||||
isc_task_send(zonetask, ISC_EVENT_PTR(&event));
|
||||
|
||||
@@ -1585,7 +1585,6 @@ respond(ns_client_t *client, isc_result_t result) {
|
||||
client->message->rcode = dns_result_torcode(result);
|
||||
|
||||
ns_client_send(client);
|
||||
isc_nmhandle_unref(client->handle);
|
||||
return;
|
||||
|
||||
msg_failure:
|
||||
@@ -1594,17 +1593,23 @@ msg_failure:
|
||||
"could not create update response message: %s",
|
||||
isc_result_totext(msg_result));
|
||||
ns_client_drop(client, msg_result);
|
||||
isc_nmhandle_unref(client->handle);
|
||||
isc_nmhandle_detach(&client->reqhandle);
|
||||
}
|
||||
|
||||
void
|
||||
ns_update_start(ns_client_t *client, isc_result_t sigresult) {
|
||||
ns_update_start(ns_client_t *client, isc_nmhandle_t *handle,
|
||||
isc_result_t sigresult) {
|
||||
dns_message_t *request = client->message;
|
||||
isc_result_t result;
|
||||
dns_name_t *zonename;
|
||||
dns_rdataset_t *zone_rdataset;
|
||||
dns_zone_t *zone = NULL, *raw = NULL;
|
||||
|
||||
/*
|
||||
* Attach to the request handle
|
||||
*/
|
||||
isc_nmhandle_attach(handle, &client->reqhandle);
|
||||
|
||||
/*
|
||||
* Interpret the zone section.
|
||||
*/
|
||||
@@ -1673,6 +1678,8 @@ ns_update_start(ns_client_t *client, isc_result_t sigresult) {
|
||||
default:
|
||||
FAILC(DNS_R_NOTAUTH, "not authoritative for update zone");
|
||||
}
|
||||
|
||||
isc_nmhandle_detach(&client->reqhandle);
|
||||
return;
|
||||
|
||||
failure:
|
||||
@@ -1690,6 +1697,7 @@ failure:
|
||||
if (zone != NULL) {
|
||||
dns_zone_detach(&zone);
|
||||
}
|
||||
isc_nmhandle_detach(&client->reqhandle);
|
||||
}
|
||||
|
||||
/*%
|
||||
@@ -3497,6 +3505,7 @@ common:
|
||||
}
|
||||
uev->ev_type = DNS_EVENT_UPDATEDONE;
|
||||
uev->ev_action = updatedone_action;
|
||||
|
||||
isc_task_send(client->task, &event);
|
||||
|
||||
INSIST(ver == NULL);
|
||||
@@ -3510,8 +3519,9 @@ updatedone_action(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
INSIST(event->ev_type == DNS_EVENT_UPDATEDONE);
|
||||
INSIST(task == client->task);
|
||||
REQUIRE(event->ev_type == DNS_EVENT_UPDATEDONE);
|
||||
REQUIRE(task == client->task);
|
||||
REQUIRE(client->updatehandle == client->handle);
|
||||
|
||||
INSIST(client->nupdates > 0);
|
||||
switch (uev->result) {
|
||||
@@ -3528,16 +3538,18 @@ updatedone_action(isc_task_t *task, isc_event_t *event) {
|
||||
if (uev->zone != NULL) {
|
||||
dns_zone_detach(&uev->zone);
|
||||
}
|
||||
|
||||
client->nupdates--;
|
||||
|
||||
respond(client, uev->result);
|
||||
|
||||
isc_event_free(&event);
|
||||
isc_nmhandle_unref(client->handle);
|
||||
isc_nmhandle_detach(&client->updatehandle);
|
||||
}
|
||||
|
||||
/*%
|
||||
* Update forwarding support.
|
||||
*/
|
||||
|
||||
static void
|
||||
forward_fail(isc_task_t *task, isc_event_t *event) {
|
||||
ns_client_t *client = (ns_client_t *)event->ev_arg;
|
||||
@@ -3548,7 +3560,7 @@ forward_fail(isc_task_t *task, isc_event_t *event) {
|
||||
client->nupdates--;
|
||||
respond(client, DNS_R_SERVFAIL);
|
||||
isc_event_free(&event);
|
||||
isc_nmhandle_unref(client->handle);
|
||||
isc_nmhandle_detach(&client->updatehandle);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3568,6 +3580,7 @@ forward_callback(void *arg, isc_result_t result, dns_message_t *answer) {
|
||||
uev->answer = answer;
|
||||
inc_stats(client, zone, ns_statscounter_updaterespfwd);
|
||||
}
|
||||
|
||||
isc_task_send(client->task, ISC_EVENT_PTR(&uev));
|
||||
dns_zone_detach(&zone);
|
||||
}
|
||||
@@ -3584,7 +3597,7 @@ forward_done(isc_task_t *task, isc_event_t *event) {
|
||||
ns_client_sendraw(client, uev->answer);
|
||||
dns_message_destroy(&uev->answer);
|
||||
isc_event_free(&event);
|
||||
isc_nmhandle_unref(client->handle);
|
||||
isc_nmhandle_detach(&client->updatehandle);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3636,7 +3649,7 @@ send_forward_event(ns_client_t *client, dns_zone_t *zone) {
|
||||
namebuf, classbuf);
|
||||
|
||||
dns_zone_gettask(zone, &zonetask);
|
||||
isc_nmhandle_ref(client->handle);
|
||||
isc_nmhandle_attach(client->handle, &client->updatehandle);
|
||||
isc_task_send(zonetask, ISC_EVENT_PTR(&event));
|
||||
|
||||
if (event != NULL) {
|
||||
|
Reference in New Issue
Block a user