Commit 1646ae97 authored by Bob Halley's avatar Bob Halley
Browse files

add dns_resolver_cancelfetch

parent beb2b4f1
......@@ -59,6 +59,7 @@ ISC_LANG_BEGINDECLS
typedef struct dns_fetchevent {
ISC_EVENT_COMMON(struct dns_fetchevent);
dns_fetch_t * fetch;
dns_result_t result;
dns_rdatatype_t qtype;
dns_db_t * db;
......@@ -96,6 +97,9 @@ dns_resolver_createfetch(dns_resolver_t *res, dns_name_t *name,
dns_rdataset_t *sigrdataset,
dns_fetch_t **fetchp);
void
dns_resolver_cancelfetch(dns_resolver_t *res, dns_fetch_t *fetch);
void
dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp);
......
......@@ -18,6 +18,7 @@
#include <config.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/result.h>
#include <isc/timer.h>
#include <isc/mutex.h>
......@@ -804,7 +805,7 @@ fctx_join(fetchctx_t *fctx, isc_task_t *task, isc_taskaction_t action,
event->node = NULL;
event->rdataset = rdataset;
event->sigrdataset = sigrdataset;
event->tag = fetch;
event->fetch = fetch;
dns_fixedname_init(&event->foundname);
ISC_LIST_APPEND(fctx->events, event, link);
......@@ -881,7 +882,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
/*
* Compute an expiration time for the entire fetch.
*/
isc_interval_set(&interval, 10, 0); /* XXXRTH constant */
isc_interval_set(&interval, 30, 0); /* XXXRTH constant */
iresult = isc_time_nowplusinterval(&fctx->expires, &interval);
if (iresult != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
......@@ -2576,19 +2577,15 @@ dns_resolver_createfetch(dns_resolver_t *res, dns_name_t *name,
}
void
dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp) {
dns_fetch_t *fetch;
dns_fetchevent_t *event, *next_event;
isc_event_t *cevent;
dns_resolver_cancelfetch(dns_resolver_t *res, dns_fetch_t *fetch) {
fetchctx_t *fctx;
dns_fetchevent_t *event, *next_event;
isc_task_t *etask;
REQUIRE(fetchp != NULL);
fetch = *fetchp;
REQUIRE(DNS_FETCH_VALID(fetch));
fctx = fetch->private;
FTRACE("destroyfetch");
FTRACE("cancelfetch");
LOCK(&res->buckets[fctx->bucketnum].lock);
......@@ -2598,10 +2595,9 @@ dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp) {
event != NULL;
event = next_event) {
next_event = ISC_LIST_NEXT(event, link);
if (event->tag == fetch) {
if (event->fetch == fetch) {
ISC_LIST_UNLINK(fctx->events, event,
link);
FTRACE("found");
break;
}
}
......@@ -2612,6 +2608,39 @@ dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp) {
isc_task_sendanddetach(&etask, (isc_event_t **)&event);
}
UNLOCK(&res->buckets[fctx->bucketnum].lock);
}
void
dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp) {
dns_fetch_t *fetch;
dns_fetchevent_t *event, *next_event;
isc_event_t *cevent;
fetchctx_t *fctx;
REQUIRE(fetchp != NULL);
fetch = *fetchp;
REQUIRE(DNS_FETCH_VALID(fetch));
fctx = fetch->private;
FTRACE("destroyfetch");
LOCK(&res->buckets[fctx->bucketnum].lock);
/*
* Sanity check. The caller should have either gotten its
* fetchevent before trying to destroy the fetch.
*/
event = NULL;
if (fctx->state != fetchstate_done) {
for (event = ISC_LIST_HEAD(fctx->events);
event != NULL;
event = next_event) {
next_event = ISC_LIST_NEXT(event, link);
RUNTIME_CHECK(event->fetch != fetch);
}
}
INSIST(fctx->references > 0);
fctx->references--;
if (fctx->references == 0) {
......
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