resolver.c revision c0de97d5db2ed05df261e28460e1f477a163ee8f
a3ab70dae26d009bf78b0594b2ab5eb9208f4b91Michael Graff#define RTRACE(m) printf("res %p: %s\n", res, (m))
a3ab70dae26d009bf78b0594b2ab5eb9208f4b91Michael Graff#define RRTRACE(r, m) printf("res %p: %s\n", (r), (m))
ae7d0a4375abaecfd5c5b0816616d9882831e69bMichael Graff#define FCTXTRACE(m) printf("fctx %p: %s\n", fctx, (m))
ae7d0a4375abaecfd5c5b0816616d9882831e69bMichael Graff#define FTRACE(m) printf("fetch %p (res %p fctx %p tag %u): %s\n", \
ae7d0a4375abaecfd5c5b0816616d9882831e69bMichael Graff fetch, fetch->res, fetch->private, fetch->tag, \
74889a341cac183d477e15cfead391a8f7bdba95Michael Grafftypedef struct query {
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Grafftypedef enum {
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Grafftypedef struct fetchctx {
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff unsigned int magic;
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff unsigned int locknum;
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff unsigned int options;
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff /* Locked by lock. */
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff /* Unlocked */
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff unsigned int magic;
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff /* Locked by lock. */
c05e003dce672b2f8555a3e56857f29ce89c1677Michael Graff unsigned int ntasks;
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff#define VALID_RESOLVER(res) ((res) != NULL && \
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff * Internal fetch routines. Caller must be holding the proper lock.
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Grafffctx_done(fetchctx_t *fctx, dns_result_t result) {
e4f074a2c2340ea80099beebecc3b89aa234fa8fMichael Graff * The caller must be holding the proper lock.
c05e003dce672b2f8555a3e56857f29ce89c1677Michael Graff iresult = isc_task_send(task, (isc_event_t **)&event);
c05e003dce672b2f8555a3e56857f29ce89c1677Michael Graff "isc_task_send(): %s",
c05e003dce672b2f8555a3e56857f29ce89c1677Michael Graff query = isc_mem_get(fctx->res->mctx, sizeof *query);
c05e003dce672b2f8555a3e56857f29ce89c1677Michael Graff /* XXXRTH do the rest of the work... */
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff /* XXXRTH do the rest of the work... */
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff isc_mem_put(fctx->res->mctx, query, sizeof *query);
291b0d910d115e41a4b69d0603c3376aebf0c630Michael Graff * Caller must be holding the fetch's lock.
291b0d910d115e41a4b69d0603c3376aebf0c630Michael Graff iresult = isc_timer_reset(fctx->timer, isc_timertype_once,
e24f605ad64182532640dc6721070456b13112d5Michael Graff "isc_timer_reset(): %s",
e24f605ad64182532640dc6721070456b13112d5Michael Graff isc_mem_put(fctx->res->mctx, fctx, sizeof *fctx);
e24f605ad64182532640dc6721070456b13112d5Michael Graff * Fetch event handlers.
e24f605ad64182532640dc6721070456b13112d5Michael Grafffctx_timeout(isc_task_t *task, isc_event_t *event) {
ae7d0a4375abaecfd5c5b0816616d9882831e69bMichael Graff * We could cancel the running queries here, or we could let
ae7d0a4375abaecfd5c5b0816616d9882831e69bMichael Graff * them keep going. Right now we choose the latter...
74889a341cac183d477e15cfead391a8f7bdba95Michael Grafffctx_start(isc_task_t *task, isc_event_t *event) {
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff isc_boolean_t need_resolver_destroy = ISC_FALSE;
74889a341cac183d477e15cfead391a8f7bdba95Michael Graff if (res->exiting && ISC_LIST_EMPTY(res->fctxs))
2311073ce0ef26c0250e91e4a083d7cc94fa7d33Michael Graff * Fetch Creation, Joining, and Cancelation.
2311073ce0ef26c0250e91e4a083d7cc94fa7d33Michael Grafffctx_join(fetchctx_t *fctx, isc_task_t *task, isc_taskaction_t action,
2311073ce0ef26c0250e91e4a083d7cc94fa7d33Michael Graff * We store the task we're going to send this event to in the
e24f605ad64182532640dc6721070456b13112d5Michael Graff * sender field. We'll make the fetch the sender when we actually
e24f605ad64182532640dc6721070456b13112d5Michael Graff * send the event.
return (DNS_R_SUCCESS);
static dns_result_t
unsigned int options,
return (DNS_R_NOMEMORY);
goto cleanup_fetch;
goto cleanup_name;
goto cleanup_message;
goto cleanup_message;
goto cleanup_timer;
goto cleanup_timer;
return (DNS_R_SUCCESS);
return (result);
static inline dns_result_t
return (DNS_R_FORMERR);
return (result);
return (DNS_R_FORMERR);
return (DNS_R_SUCCESS);
switch (result) {
case DNS_R_FORMERR:
case DNS_R_UNEXPECTEDEND:
case DNS_R_MOREDATA:
goto done;
goto done;
goto done;
goto done;
done:
if (bad_sender) {
unsigned int i, tasks_created = 0;
return (DNS_R_NOMEMORY);
goto cleanup_res;
for (i = 0; i < ntasks; i++) {
goto cleanup_tasks;
goto cleanup_tasks;
return (DNS_R_SUCCESS);
for (i = 0; i < tasks_created; i++) {
return (result);
if (need_destroy)
static inline isc_boolean_t
unsigned int options)
return (ISC_FALSE);
(void)delegation;
(void)forwarders;
return (DNS_R_NOTIMPLEMENTED);
return (DNS_R_NOMEMORY);
fetch);
return (result);
if (need_fctx_destroy)