Commit aceabacd authored by Mark Andrews's avatar Mark Andrews
Browse files

4538. [bug] Call dns_client_startresolve from client->task.

                        [RT #43896]
parent e17d2f98
4538. [bug] Call dns_client_startresolve from client->task.
[RT #43896]
4537. [bug] Handle timouts better in dig/host/nslookup. [RT #43576]
4536. [bug] ISC_SOCKEVENTATTR_USEMINMTU was not being cleared
......
......@@ -2772,6 +2772,48 @@ dns_client_update(dns_client_t *client, dns_rdataclass_t rdclass,
return (result);
}
static void
runintask(isc_task_t *task, isc_event_t *event) {
updatectx_t *uctx;
isc_result_t result;
unsigned int resoptions;
REQUIRE(event != NULL);
UNUSED(task);
uctx = event->ev_arg;
if (uctx->zonename != NULL && uctx->currentserver != NULL) {
result = send_update(uctx);
if (result != ISC_R_SUCCESS)
goto fail;
} else if (uctx->currentserver != NULL) {
result = request_soa(uctx);
if (result != ISC_R_SUCCESS)
goto fail;
} else {
resoptions = 0;
if (uctx->want_tcp)
resoptions |= DNS_CLIENTRESOPT_TCP;
dns_name_clone(uctx->firstname, &uctx->soaqname);
result = dns_client_startresolve(uctx->client, &uctx->soaqname,
uctx->rdclass,
dns_rdatatype_soa, resoptions,
uctx->client->task,
resolvesoa_done, uctx,
&uctx->restrans);
if (result != ISC_R_SUCCESS)
goto fail;
}
isc_event_free(&event);
fail:
if (result != ISC_R_SUCCESS)
update_sendevent(uctx, result);
}
isc_result_t
dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
dns_name_t *zonename, dns_namelist_t *prerequisites,
......@@ -2789,7 +2831,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
isc_sockaddr_t *server, *sa = NULL;
dns_tsectype_t tsectype = dns_tsectype_none;
isc_boolean_t want_tcp;
unsigned int resoptions;
isc_event_t *runinevent;
UNUSED(options);
......@@ -2810,20 +2852,36 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
UNLOCK(&client->lock);
if (result != ISC_R_SUCCESS)
return (result);
want_tcp = ISC_TF((options & DNS_CLIENTUPDOPT_TCP) != 0);
/* Create a context and prepare some resources */
/*
* Create a context and prepare some resources.
*/
uctx = isc_mem_get(client->mctx, sizeof(*uctx));
if (uctx == NULL) {
dns_view_detach(&view);
return (ISC_R_NOMEMORY);
}
runinevent = isc_event_allocate(client->mctx, client->task,
DNS_EVENT_RUNIN, runintask,
uctx, sizeof(*runinevent));
if (runinevent == NULL) {
dns_view_detach(&view);
isc_mem_put(client->mctx, uctx, sizeof(*uctx));
return (ISC_R_NOMEMORY);
}
result = isc_mutex_init(&uctx->lock);
if (result != ISC_R_SUCCESS) {
dns_view_detach(&view);
isc_event_free(&runinevent);
isc_mem_put(client->mctx, uctx, sizeof(*uctx));
return (ISC_R_NOMEMORY);
}
tclone = NULL;
isc_task_attach(task, &tclone);
uctx->client = client;
......@@ -2925,33 +2983,14 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
ISC_LIST_APPEND(client->updatectxs, uctx, link);
UNLOCK(&client->lock);
if (uctx->zonename != NULL && uctx->currentserver != NULL) {
result = send_update(uctx);
if (result != ISC_R_SUCCESS)
goto fail;
} else if (uctx->currentserver != NULL) {
result = request_soa(uctx);
if (result != ISC_R_SUCCESS)
goto fail;
} else {
resoptions = 0;
if (want_tcp)
resoptions |= DNS_CLIENTRESOPT_TCP;
dns_name_clone(uctx->firstname, &uctx->soaqname);
result = dns_client_startresolve(uctx->client, &uctx->soaqname,
uctx->rdclass,
dns_rdatatype_soa, resoptions,
client->task, resolvesoa_done,
uctx, &uctx->restrans);
if (result != ISC_R_SUCCESS)
goto fail;
}
*transp = (dns_clientupdatetrans_t *)uctx;
isc_task_send(client->task, &runinevent);
return (ISC_R_SUCCESS);
fail:
if (runinevent != NULL)
isc_event_free(&runinevent);
if (ISC_LINK_LINKED(uctx, link)) {
LOCK(&client->lock);
ISC_LIST_UNLINK(client->updatectxs, uctx, link);
......
......@@ -75,6 +75,7 @@
#define DNS_EVENT_CATZADDZONE (ISC_EVENTCLASS_DNS + 54)
#define DNS_EVENT_CATZMODZONE (ISC_EVENTCLASS_DNS + 55)
#define DNS_EVENT_CATZDELZONE (ISC_EVENTCLASS_DNS + 56)
#define DNS_EVENT_RUNIN (ISC_EVENTCLASS_DNS + 57)
#define DNS_EVENT_FIRSTEVENT (ISC_EVENTCLASS_DNS + 0)
#define DNS_EVENT_LASTEVENT (ISC_EVENTCLASS_DNS + 65535)
......
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