mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-28 04:58:04 +00:00
replace all instances of 'handle' with 'find' since that's what they are now.
This commit is contained in:
parent
2992344aac
commit
c803787146
@ -44,7 +44,7 @@ typedef struct client client_t;
|
|||||||
struct client {
|
struct client {
|
||||||
dns_name_t name;
|
dns_name_t name;
|
||||||
ISC_LINK(client_t) link;
|
ISC_LINK(client_t) link;
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
};
|
};
|
||||||
|
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
@ -175,7 +175,7 @@ new_client(void)
|
|||||||
INSIST(client != NULL);
|
INSIST(client != NULL);
|
||||||
dns_name_init(&client->name, NULL);
|
dns_name_init(&client->name, NULL);
|
||||||
ISC_LINK_INIT(client, link);
|
ISC_LINK_INIT(client, link);
|
||||||
client->handle = NULL;
|
client->find = NULL;
|
||||||
|
|
||||||
return (client);
|
return (client);
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ free_client(client_t **c)
|
|||||||
INSIST(client != NULL);
|
INSIST(client != NULL);
|
||||||
dns_name_free(&client->name, mctx);
|
dns_name_free(&client->name, mctx);
|
||||||
INSIST(!ISC_LINK_LINKED(client, link));
|
INSIST(!ISC_LINK_LINKED(client, link));
|
||||||
INSIST(client->handle == NULL);
|
INSIST(client->find == NULL);
|
||||||
|
|
||||||
isc_mempool_put(cmp, client);
|
isc_mempool_put(cmp, client);
|
||||||
}
|
}
|
||||||
@ -214,17 +214,17 @@ lookup_callback(isc_task_t *task, isc_event_t *ev)
|
|||||||
client_t *client;
|
client_t *client;
|
||||||
|
|
||||||
client = ev->arg;
|
client = ev->arg;
|
||||||
INSIST(client->handle == ev->sender);
|
INSIST(client->find == ev->sender);
|
||||||
|
|
||||||
printf("Task %p got event %p type %08x from %p, client %p\n",
|
printf("Task %p got event %p type %08x from %p, client %p\n",
|
||||||
task, ev, ev->type, client->handle, client);
|
task, ev, ev->type, client->find, client);
|
||||||
|
|
||||||
isc_event_free(&ev);
|
isc_event_free(&ev);
|
||||||
|
|
||||||
CLOCK();
|
CLOCK();
|
||||||
|
|
||||||
dns_adb_dumphandle(client->handle, stderr);
|
dns_adb_dumpfind(client->find, stderr);
|
||||||
dns_adb_destroyfind(&client->handle);
|
dns_adb_destroyfind(&client->find);
|
||||||
|
|
||||||
ISC_LIST_UNLINK(clients, client, link);
|
ISC_LIST_UNLINK(clients, client, link);
|
||||||
free_client(&client);
|
free_client(&client);
|
||||||
@ -347,14 +347,14 @@ lookup(char *target)
|
|||||||
result = dns_adb_createfind(adb, t2, lookup_callback, client,
|
result = dns_adb_createfind(adb, t2, lookup_callback, client,
|
||||||
&client->name, dns_rootname,
|
&client->name, dns_rootname,
|
||||||
(DNS_ADBFIND_INET | DNS_ADBFIND_WANTEVENT),
|
(DNS_ADBFIND_INET | DNS_ADBFIND_WANTEVENT),
|
||||||
now, &client->handle);
|
now, &client->find);
|
||||||
check_result(result, "dns_adb_lookup()");
|
check_result(result, "dns_adb_lookup()");
|
||||||
dns_adb_dumphandle(client->handle, stderr);
|
dns_adb_dumpfind(client->find, stderr);
|
||||||
|
|
||||||
if ((client->handle->options & DNS_ADBFIND_WANTEVENT) != 0)
|
if ((client->find->options & DNS_ADBFIND_WANTEVENT) != 0)
|
||||||
ISC_LIST_APPEND(clients, client, link);
|
ISC_LIST_APPEND(clients, client, link);
|
||||||
else {
|
else {
|
||||||
dns_adb_destroyfind(&client->handle);
|
dns_adb_destroyfind(&client->find);
|
||||||
free_client(&client);
|
free_client(&client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
300
lib/dns/adb.c
300
lib/dns/adb.c
@ -19,7 +19,7 @@
|
|||||||
* Implementation notes
|
* Implementation notes
|
||||||
* --------------------
|
* --------------------
|
||||||
*
|
*
|
||||||
* In handles, if task == NULL, no events will be generated, and no events
|
* In finds, if task == NULL, no events will be generated, and no events
|
||||||
* have been sent. If task != NULL but taskaction == NULL, an event has been
|
* have been sent. If task != NULL but taskaction == NULL, an event has been
|
||||||
* posted but not yet freed. If neigher are NULL, no event was posted.
|
* posted but not yet freed. If neigher are NULL, no event was posted.
|
||||||
*
|
*
|
||||||
@ -152,7 +152,7 @@ struct dns_adbname {
|
|||||||
dns_adbnamehooklist_t v4;
|
dns_adbnamehooklist_t v4;
|
||||||
dns_adbnamehooklist_t v6;
|
dns_adbnamehooklist_t v6;
|
||||||
ISC_LIST(dns_adbfetch_t) fetches;
|
ISC_LIST(dns_adbfetch_t) fetches;
|
||||||
ISC_LIST(dns_adbfind_t) handles;
|
ISC_LIST(dns_adbfind_t) finds;
|
||||||
ISC_LINK(dns_adbname_t) plink;
|
ISC_LINK(dns_adbname_t) plink;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -226,8 +226,8 @@ static inline dns_adbzoneinfo_t *new_adbzoneinfo(dns_adb_t *, dns_name_t *);
|
|||||||
static inline void free_adbzoneinfo(dns_adb_t *, dns_adbzoneinfo_t **);
|
static inline void free_adbzoneinfo(dns_adb_t *, dns_adbzoneinfo_t **);
|
||||||
static inline dns_adbentry_t *new_adbentry(dns_adb_t *);
|
static inline dns_adbentry_t *new_adbentry(dns_adb_t *);
|
||||||
static inline void free_adbentry(dns_adb_t *, dns_adbentry_t **);
|
static inline void free_adbentry(dns_adb_t *, dns_adbentry_t **);
|
||||||
static inline dns_adbfind_t *new_adbhandle(dns_adb_t *);
|
static inline dns_adbfind_t *new_adbfind(dns_adb_t *);
|
||||||
static inline void free_adbhandle(dns_adb_t *, dns_adbfind_t **);
|
static inline void free_adbfind(dns_adb_t *, dns_adbfind_t **);
|
||||||
static inline dns_adbaddrinfo_t *new_adbaddrinfo(dns_adb_t *,
|
static inline dns_adbaddrinfo_t *new_adbaddrinfo(dns_adb_t *,
|
||||||
dns_adbentry_t *);
|
dns_adbentry_t *);
|
||||||
static inline dns_adbfetch_t *new_adbfetch(dns_adb_t *);
|
static inline dns_adbfetch_t *new_adbfetch(dns_adb_t *);
|
||||||
@ -240,7 +240,7 @@ static inline dns_adbentry_t *find_entry_and_lock(dns_adb_t *,
|
|||||||
static void dump_adb(dns_adb_t *, FILE *);
|
static void dump_adb(dns_adb_t *, FILE *);
|
||||||
static void print_dns_name(FILE *, dns_name_t *);
|
static void print_dns_name(FILE *, dns_name_t *);
|
||||||
static void print_namehook_list(FILE *, dns_adbname_t *);
|
static void print_namehook_list(FILE *, dns_adbname_t *);
|
||||||
static void print_handle_list(FILE *, dns_adbname_t *);
|
static void print_find_list(FILE *, dns_adbname_t *);
|
||||||
static void print_fetch_list(FILE *, dns_adbname_t *);
|
static void print_fetch_list(FILE *, dns_adbname_t *);
|
||||||
static inline void inc_adb_irefcnt(dns_adb_t *, isc_boolean_t);
|
static inline void inc_adb_irefcnt(dns_adb_t *, isc_boolean_t);
|
||||||
static inline void dec_adb_irefcnt(dns_adb_t *, isc_boolean_t);
|
static inline void dec_adb_irefcnt(dns_adb_t *, isc_boolean_t);
|
||||||
@ -252,7 +252,7 @@ static inline void dec_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
|
|||||||
isc_boolean_t);
|
isc_boolean_t);
|
||||||
static inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
|
static inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
|
||||||
static void clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *);
|
static void clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *);
|
||||||
static void clean_handles_at_name(dns_adbname_t *, isc_eventtype_t);
|
static void clean_finds_at_name(dns_adbname_t *, isc_eventtype_t);
|
||||||
static void check_expire_namehooks(dns_adbname_t *, isc_stdtime_t);
|
static void check_expire_namehooks(dns_adbname_t *, isc_stdtime_t);
|
||||||
static void cancel_fetches_at_name(dns_adb_t *, dns_adbname_t *);
|
static void cancel_fetches_at_name(dns_adb_t *, dns_adbname_t *);
|
||||||
static isc_result_t dbfind_name_v4(dns_adbfind_t *, dns_name_t *,
|
static isc_result_t dbfind_name_v4(dns_adbfind_t *, dns_name_t *,
|
||||||
@ -266,11 +266,11 @@ static inline void link_name(dns_adb_t *, int, dns_adbname_t *);
|
|||||||
static inline void unlink_name(dns_adb_t *, dns_adbname_t *);
|
static inline void unlink_name(dns_adb_t *, dns_adbname_t *);
|
||||||
static void kill_name(dns_adbname_t **, isc_eventtype_t ev);
|
static void kill_name(dns_adbname_t **, isc_eventtype_t ev);
|
||||||
|
|
||||||
#define HANDLE_EVENT_SENT 0x00000001
|
#define FIND_EVENT_SENT 0x00000001
|
||||||
#define HANDLE_EVENT_FREED 0x00000002
|
#define FIND_EVENT_FREED 0x00000002
|
||||||
|
|
||||||
#define EVENT_SENT(h) (((h)->flags & HANDLE_EVENT_SENT) != 0)
|
#define EVENT_SENT(h) (((h)->flags & FIND_EVENT_SENT) != 0)
|
||||||
#define EVENT_FREED(h) (((h)->flags & HANDLE_EVENT_FREED) != 0)
|
#define EVENT_FREED(h) (((h)->flags & FIND_EVENT_FREED) != 0)
|
||||||
|
|
||||||
#define WANTEVENT(x) (((x) & DNS_ADBFIND_WANTEVENT) != 0)
|
#define WANTEVENT(x) (((x) & DNS_ADBFIND_WANTEVENT) != 0)
|
||||||
#define WANTEMPTYEVENT(x) (((x) & DNS_ADBFIND_EMPTYEVENT) != 0)
|
#define WANTEMPTYEVENT(x) (((x) & DNS_ADBFIND_EMPTYEVENT) != 0)
|
||||||
@ -401,7 +401,7 @@ kill_name(dns_adbname_t **n, isc_eventtype_t ev)
|
|||||||
* Clean up the name's various lists. These two are destructive
|
* Clean up the name's various lists. These two are destructive
|
||||||
* in that they will always empty the list.
|
* in that they will always empty the list.
|
||||||
*/
|
*/
|
||||||
clean_handles_at_name(name, ev);
|
clean_finds_at_name(name, ev);
|
||||||
clean_namehooks(adb, &name->v4);
|
clean_namehooks(adb, &name->v4);
|
||||||
clean_namehooks(adb, &name->v6);
|
clean_namehooks(adb, &name->v6);
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ shutdown_names(dns_adb_t *adb)
|
|||||||
adb->name_sd[bucket] = ISC_TRUE;
|
adb->name_sd[bucket] = ISC_TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run through the list. For each name, clean up handles
|
* Run through the list. For each name, clean up finds
|
||||||
* found there, and cancel any fetches running. When
|
* found there, and cancel any fetches running. When
|
||||||
* all the fetches are canceled, the name will destroy
|
* all the fetches are canceled, the name will destroy
|
||||||
* itself.
|
* itself.
|
||||||
@ -593,57 +593,57 @@ clean_namehooks(dns_adb_t *adb, dns_adbnamehooklist_t *namehooks)
|
|||||||
static void
|
static void
|
||||||
event_free(isc_event_t *event)
|
event_free(isc_event_t *event)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
|
|
||||||
INSIST(event != NULL);
|
INSIST(event != NULL);
|
||||||
handle = event->destroy_arg;
|
find = event->destroy_arg;
|
||||||
INSIST(DNS_ADBFIND_VALID(handle));
|
INSIST(DNS_ADBFIND_VALID(find));
|
||||||
|
|
||||||
LOCK(&handle->lock);
|
LOCK(&find->lock);
|
||||||
handle->flags |= HANDLE_EVENT_FREED;
|
find->flags |= FIND_EVENT_FREED;
|
||||||
event->destroy_arg = NULL;
|
event->destroy_arg = NULL;
|
||||||
UNLOCK(&handle->lock);
|
UNLOCK(&find->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assumes the name bucket is locked.
|
* Assumes the name bucket is locked.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
clean_handles_at_name(dns_adbname_t *name, isc_eventtype_t evtype)
|
clean_finds_at_name(dns_adbname_t *name, isc_eventtype_t evtype)
|
||||||
{
|
{
|
||||||
isc_event_t *ev;
|
isc_event_t *ev;
|
||||||
isc_task_t *task;
|
isc_task_t *task;
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
|
|
||||||
handle = ISC_LIST_HEAD(name->handles);
|
find = ISC_LIST_HEAD(name->finds);
|
||||||
while (handle != NULL) {
|
while (find != NULL) {
|
||||||
LOCK(&handle->lock);
|
LOCK(&find->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlink the handle from the name, letting the caller
|
* Unlink the find from the name, letting the caller
|
||||||
* call dns_adb_destroyfind() on it to clean it up later.
|
* call dns_adb_destroyfind() on it to clean it up later.
|
||||||
*/
|
*/
|
||||||
ISC_LIST_UNLINK(name->handles, handle, plink);
|
ISC_LIST_UNLINK(name->finds, find, plink);
|
||||||
handle->adbname = NULL;
|
find->adbname = NULL;
|
||||||
handle->name_bucket = DNS_ADB_INVALIDBUCKET;
|
find->name_bucket = DNS_ADB_INVALIDBUCKET;
|
||||||
|
|
||||||
INSIST(!EVENT_SENT(handle));
|
INSIST(!EVENT_SENT(find));
|
||||||
|
|
||||||
ev = &handle->event;
|
ev = &find->event;
|
||||||
task = ev->sender;
|
task = ev->sender;
|
||||||
ev->sender = handle;
|
ev->sender = find;
|
||||||
ev->type = evtype;
|
ev->type = evtype;
|
||||||
ev->destroy = event_free;
|
ev->destroy = event_free;
|
||||||
ev->destroy_arg = handle;
|
ev->destroy_arg = find;
|
||||||
|
|
||||||
DP(("Sending event %p to task %p for handle %p\n",
|
DP(("Sending event %p to task %p for find %p\n",
|
||||||
ev, task, handle));
|
ev, task, find));
|
||||||
|
|
||||||
isc_task_sendanddetach(&task, &ev);
|
isc_task_sendanddetach(&task, &ev);
|
||||||
|
|
||||||
UNLOCK(&handle->lock);
|
UNLOCK(&find->lock);
|
||||||
|
|
||||||
handle = ISC_LIST_HEAD(name->handles);
|
find = ISC_LIST_HEAD(name->finds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,7 +782,7 @@ new_adbname(dns_adb_t *adb, dns_name_t *dnsname)
|
|||||||
ISC_LIST_INIT(name->v4);
|
ISC_LIST_INIT(name->v4);
|
||||||
ISC_LIST_INIT(name->v6);
|
ISC_LIST_INIT(name->v6);
|
||||||
ISC_LIST_INIT(name->fetches);
|
ISC_LIST_INIT(name->fetches);
|
||||||
ISC_LIST_INIT(name->handles);
|
ISC_LIST_INIT(name->finds);
|
||||||
ISC_LINK_INIT(name, plink);
|
ISC_LINK_INIT(name, plink);
|
||||||
|
|
||||||
return (name);
|
return (name);
|
||||||
@ -799,7 +799,7 @@ free_adbname(dns_adb_t *adb, dns_adbname_t **name)
|
|||||||
|
|
||||||
INSIST(!HAVE_INET(n));
|
INSIST(!HAVE_INET(n));
|
||||||
INSIST(ISC_LIST_EMPTY(n->fetches));
|
INSIST(ISC_LIST_EMPTY(n->fetches));
|
||||||
INSIST(ISC_LIST_EMPTY(n->handles));
|
INSIST(ISC_LIST_EMPTY(n->finds));
|
||||||
INSIST(!ISC_LINK_LINKED(n, plink));
|
INSIST(!ISC_LINK_LINKED(n, plink));
|
||||||
INSIST(n->lock_bucket == DNS_ADB_INVALIDBUCKET);
|
INSIST(n->lock_bucket == DNS_ADB_INVALIDBUCKET);
|
||||||
INSIST(n->adb == adb);
|
INSIST(n->adb == adb);
|
||||||
@ -932,7 +932,7 @@ free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline dns_adbfind_t *
|
static inline dns_adbfind_t *
|
||||||
new_adbhandle(dns_adb_t *adb)
|
new_adbfind(dns_adb_t *adb)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *h;
|
dns_adbfind_t *h;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@ -962,7 +962,7 @@ new_adbhandle(dns_adb_t *adb)
|
|||||||
result = isc_mutex_init(&h->lock);
|
result = isc_mutex_init(&h->lock);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"isc_mutex_init failed in new_adbhandle()");
|
"isc_mutex_init failed in new_adbfind()");
|
||||||
isc_mempool_put(adb->ahmp, h);
|
isc_mempool_put(adb->ahmp, h);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -1037,24 +1037,24 @@ free_adbfetch(dns_adb_t *adb, dns_adbfetch_t **fetch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
free_adbhandle(dns_adb_t *adb, dns_adbfind_t **handlep)
|
free_adbfind(dns_adb_t *adb, dns_adbfind_t **findp)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
|
|
||||||
INSIST(handlep != NULL && DNS_ADBFIND_VALID(*handlep));
|
INSIST(findp != NULL && DNS_ADBFIND_VALID(*findp));
|
||||||
handle = *handlep;
|
find = *findp;
|
||||||
*handlep = NULL;
|
*findp = NULL;
|
||||||
|
|
||||||
INSIST(!HAVE_ADDRS(handle));
|
INSIST(!HAVE_ADDRS(find));
|
||||||
INSIST(!ISC_LINK_LINKED(handle, publink));
|
INSIST(!ISC_LINK_LINKED(find, publink));
|
||||||
INSIST(!ISC_LINK_LINKED(handle, plink));
|
INSIST(!ISC_LINK_LINKED(find, plink));
|
||||||
INSIST(handle->name_bucket == DNS_ADB_INVALIDBUCKET);
|
INSIST(find->name_bucket == DNS_ADB_INVALIDBUCKET);
|
||||||
INSIST(handle->adbname == NULL);
|
INSIST(find->adbname == NULL);
|
||||||
|
|
||||||
handle->magic = 0;
|
find->magic = 0;
|
||||||
|
|
||||||
isc_mutex_destroy(&handle->lock);
|
isc_mutex_destroy(&find->lock);
|
||||||
isc_mempool_put(adb->ahmp, handle);
|
isc_mempool_put(adb->ahmp, find);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1217,7 +1217,7 @@ entry_is_bad_for_zone(dns_adb_t *adb, dns_adbentry_t *entry, dns_name_t *zone,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *handle,
|
copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||||
dns_adbname_t *name, dns_name_t *zone, isc_stdtime_t now)
|
dns_adbname_t *name, dns_name_t *zone, isc_stdtime_t now)
|
||||||
{
|
{
|
||||||
dns_adbnamehook_t *namehook;
|
dns_adbnamehook_t *namehook;
|
||||||
@ -1226,7 +1226,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *handle,
|
|||||||
|
|
||||||
bucket = DNS_ADB_INVALIDBUCKET;
|
bucket = DNS_ADB_INVALIDBUCKET;
|
||||||
|
|
||||||
if (handle->options & DNS_ADBFIND_INET) {
|
if (find->options & DNS_ADBFIND_INET) {
|
||||||
namehook = ISC_LIST_HEAD(name->v4);
|
namehook = ISC_LIST_HEAD(name->v4);
|
||||||
while (namehook != NULL) {
|
while (namehook != NULL) {
|
||||||
bucket = namehook->entry->lock_bucket;
|
bucket = namehook->entry->lock_bucket;
|
||||||
@ -1236,14 +1236,14 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *handle,
|
|||||||
goto nextv4;
|
goto nextv4;
|
||||||
addrinfo = new_adbaddrinfo(adb, namehook->entry);
|
addrinfo = new_adbaddrinfo(adb, namehook->entry);
|
||||||
if (addrinfo == NULL) {
|
if (addrinfo == NULL) {
|
||||||
handle->partial_result |= DNS_ADBFIND_INET;
|
find->partial_result |= DNS_ADBFIND_INET;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Found a valid entry. Add it to the handle's list.
|
* Found a valid entry. Add it to the find's list.
|
||||||
*/
|
*/
|
||||||
inc_entry_refcnt(adb, namehook->entry, ISC_FALSE);
|
inc_entry_refcnt(adb, namehook->entry, ISC_FALSE);
|
||||||
ISC_LIST_APPEND(handle->list, addrinfo, publink);
|
ISC_LIST_APPEND(find->list, addrinfo, publink);
|
||||||
addrinfo = NULL;
|
addrinfo = NULL;
|
||||||
nextv4:
|
nextv4:
|
||||||
UNLOCK(&adb->entrylocks[bucket]);
|
UNLOCK(&adb->entrylocks[bucket]);
|
||||||
@ -1252,7 +1252,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *handle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->options & DNS_ADBFIND_INET) {
|
if (find->options & DNS_ADBFIND_INET) {
|
||||||
namehook = ISC_LIST_HEAD(name->v6);
|
namehook = ISC_LIST_HEAD(name->v6);
|
||||||
while (namehook != NULL) {
|
while (namehook != NULL) {
|
||||||
bucket = namehook->entry->lock_bucket;
|
bucket = namehook->entry->lock_bucket;
|
||||||
@ -1262,14 +1262,14 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *handle,
|
|||||||
goto nextv6;
|
goto nextv6;
|
||||||
addrinfo = new_adbaddrinfo(adb, namehook->entry);
|
addrinfo = new_adbaddrinfo(adb, namehook->entry);
|
||||||
if (addrinfo == NULL) {
|
if (addrinfo == NULL) {
|
||||||
handle->partial_result |= DNS_ADBFIND_INET;
|
find->partial_result |= DNS_ADBFIND_INET;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Found a valid entry. Add it to the handle's list.
|
* Found a valid entry. Add it to the find's list.
|
||||||
*/
|
*/
|
||||||
inc_entry_refcnt(adb, namehook->entry, ISC_FALSE);
|
inc_entry_refcnt(adb, namehook->entry, ISC_FALSE);
|
||||||
ISC_LIST_APPEND(handle->list, addrinfo, publink);
|
ISC_LIST_APPEND(find->list, addrinfo, publink);
|
||||||
addrinfo = NULL;
|
addrinfo = NULL;
|
||||||
nextv6:
|
nextv6:
|
||||||
UNLOCK(&adb->entrylocks[bucket]);
|
UNLOCK(&adb->entrylocks[bucket]);
|
||||||
@ -1466,7 +1466,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
|||||||
MPINIT(dns_adbnamehook_t, adb->nhmp, ISC_TRUE, "adbnamehook");
|
MPINIT(dns_adbnamehook_t, adb->nhmp, ISC_TRUE, "adbnamehook");
|
||||||
MPINIT(dns_adbzoneinfo_t, adb->zimp, ISC_TRUE, "adbzoneinfo");
|
MPINIT(dns_adbzoneinfo_t, adb->zimp, ISC_TRUE, "adbzoneinfo");
|
||||||
MPINIT(dns_adbentry_t, adb->emp, ISC_TRUE, "adbentry");
|
MPINIT(dns_adbentry_t, adb->emp, ISC_TRUE, "adbentry");
|
||||||
MPINIT(dns_adbfind_t, adb->ahmp, ISC_TRUE, "adbhandle");
|
MPINIT(dns_adbfind_t, adb->ahmp, ISC_TRUE, "adbfind");
|
||||||
MPINIT(dns_adbaddrinfo_t, adb->aimp, ISC_TRUE, "adbaddrinfo");
|
MPINIT(dns_adbaddrinfo_t, adb->aimp, ISC_TRUE, "adbaddrinfo");
|
||||||
MPINIT(dns_adbfetch_t, adb->afmp, ISC_TRUE, "adbfetch");
|
MPINIT(dns_adbfetch_t, adb->afmp, ISC_TRUE, "adbfetch");
|
||||||
|
|
||||||
@ -1554,9 +1554,9 @@ isc_result_t
|
|||||||
dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
||||||
void *arg, dns_name_t *name, dns_name_t *zone,
|
void *arg, dns_name_t *name, dns_name_t *zone,
|
||||||
unsigned int options, isc_stdtime_t now,
|
unsigned int options, isc_stdtime_t now,
|
||||||
dns_adbfind_t **handlep)
|
dns_adbfind_t **findp)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
dns_adbname_t *adbname;
|
dns_adbname_t *adbname;
|
||||||
int bucket;
|
int bucket;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@ -1569,7 +1569,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
}
|
}
|
||||||
REQUIRE(name != NULL);
|
REQUIRE(name != NULL);
|
||||||
REQUIRE(zone != NULL);
|
REQUIRE(zone != NULL);
|
||||||
REQUIRE(handlep != NULL && *handlep == NULL);
|
REQUIRE(findp != NULL && *findp == NULL);
|
||||||
|
|
||||||
if (WANTEVENT(options)) {
|
if (WANTEVENT(options)) {
|
||||||
REQUIRE(task != NULL);
|
REQUIRE(task != NULL);
|
||||||
@ -1603,14 +1603,14 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
* list and remember to tell the caller that there will be
|
* list and remember to tell the caller that there will be
|
||||||
* more info coming later.
|
* more info coming later.
|
||||||
*/
|
*/
|
||||||
handle = new_adbhandle(adb);
|
find = new_adbfind(adb);
|
||||||
if (handle == NULL)
|
if (find == NULL)
|
||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remember what types of addresses we are interested in.
|
* Remember what types of addresses we are interested in.
|
||||||
*/
|
*/
|
||||||
handle->options = options;
|
find->options = options;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to see if we know anything about this name at all.
|
* Try to see if we know anything about this name at all.
|
||||||
@ -1619,7 +1619,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
adbname = find_name_and_lock(adb, name, &bucket);
|
adbname = find_name_and_lock(adb, name, &bucket);
|
||||||
if (adb->name_sd[bucket]) {
|
if (adb->name_sd[bucket]) {
|
||||||
DP(("lookup: returning ISC_R_SHUTTINGDOWN\n"));
|
DP(("lookup: returning ISC_R_SHUTTINGDOWN\n"));
|
||||||
free_adbhandle(adb, &handle);
|
free_adbfind(adb, &find);
|
||||||
result = ISC_R_SHUTTINGDOWN;
|
result = ISC_R_SHUTTINGDOWN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1630,7 +1630,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
if (adbname == NULL) {
|
if (adbname == NULL) {
|
||||||
adbname = new_adbname(adb, name);
|
adbname = new_adbname(adb, name);
|
||||||
if (adbname == NULL) {
|
if (adbname == NULL) {
|
||||||
free_adbhandle(adb, &handle);
|
free_adbfind(adb, &find);
|
||||||
result = ISC_R_NOMEMORY;
|
result = ISC_R_NOMEMORY;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1649,7 +1649,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
if (!HAVE_INET(adbname)
|
if (!HAVE_INET(adbname)
|
||||||
&& !QUERY_INET(adbname->query_pending)
|
&& !QUERY_INET(adbname->query_pending)
|
||||||
&& WANT_INET(wanted_addresses)) {
|
&& WANT_INET(wanted_addresses)) {
|
||||||
result = dbfind_name_v4(handle, zone, adbname, bucket, now);
|
result = dbfind_name_v4(find, zone, adbname, bucket, now);
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
DP(("lookup: Found v4 for name %p in db\n", adbname));
|
DP(("lookup: Found v4 for name %p in db\n", adbname));
|
||||||
goto v6;
|
goto v6;
|
||||||
@ -1678,20 +1678,20 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
* Run through the name and copy out the bits we are
|
* Run through the name and copy out the bits we are
|
||||||
* interested in.
|
* interested in.
|
||||||
*/
|
*/
|
||||||
copy_namehook_lists(adb, handle, adbname, zone, now);
|
copy_namehook_lists(adb, find, adbname, zone, now);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach to the name's query list if there are queries
|
* Attach to the name's query list if there are queries
|
||||||
* already running, and we have been asked to.
|
* already running, and we have been asked to.
|
||||||
*/
|
*/
|
||||||
if (WANTEVENT(handle->options)
|
if (WANTEVENT(find->options)
|
||||||
&& QUERYPENDING(wanted_addresses, adbname->query_pending)
|
&& QUERYPENDING(wanted_addresses, adbname->query_pending)
|
||||||
&& (WANTEMPTYEVENT(handle->options) ? HAVE_ADDRS(handle) : 1)) {
|
&& (WANTEMPTYEVENT(find->options) ? HAVE_ADDRS(find) : 1)) {
|
||||||
handle->adbname = adbname;
|
find->adbname = adbname;
|
||||||
handle->name_bucket = bucket;
|
find->name_bucket = bucket;
|
||||||
ISC_LIST_APPEND(adbname->handles, handle, plink);
|
ISC_LIST_APPEND(adbname->finds, find, plink);
|
||||||
attach_to_task = ISC_TRUE;
|
attach_to_task = ISC_TRUE;
|
||||||
handle->query_pending = (adbname->query_pending
|
find->query_pending = (adbname->query_pending
|
||||||
& wanted_addresses);
|
& wanted_addresses);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -1700,25 +1700,25 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
* the event was sent and freed, so dns_adb_destroyfind() will
|
* the event was sent and freed, so dns_adb_destroyfind() will
|
||||||
* do the right thing.
|
* do the right thing.
|
||||||
*/
|
*/
|
||||||
handle->options &= ~DNS_ADBFIND_WANTEVENT;
|
find->options &= ~DNS_ADBFIND_WANTEVENT;
|
||||||
handle->flags |= (HANDLE_EVENT_SENT | HANDLE_EVENT_FREED);
|
find->flags |= (FIND_EVENT_SENT | FIND_EVENT_FREED);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->partial_result |= (adbname->partial_result & wanted_addresses);
|
find->partial_result |= (adbname->partial_result & wanted_addresses);
|
||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (handle != NULL) {
|
if (find != NULL) {
|
||||||
*handlep = handle;
|
*findp = find;
|
||||||
|
|
||||||
if (attach_to_task) {
|
if (attach_to_task) {
|
||||||
isc_task_t *taskp;
|
isc_task_t *taskp;
|
||||||
|
|
||||||
taskp = NULL;
|
taskp = NULL;
|
||||||
isc_task_attach(task, &taskp);
|
isc_task_attach(task, &taskp);
|
||||||
handle->event.sender = taskp;
|
find->event.sender = taskp;
|
||||||
handle->event.action = action;
|
find->event.action = action;
|
||||||
handle->event.arg = arg;
|
find->event.arg = arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1901,114 +1901,114 @@ dns_adb_insert(dns_adb_t *adb, dns_name_t *host, isc_sockaddr_t *addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_destroyfind(dns_adbfind_t **handlep)
|
dns_adb_destroyfind(dns_adbfind_t **findp)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
dns_adbentry_t *entry;
|
dns_adbentry_t *entry;
|
||||||
dns_adbaddrinfo_t *ai;
|
dns_adbaddrinfo_t *ai;
|
||||||
int bucket;
|
int bucket;
|
||||||
dns_adb_t *adb;
|
dns_adb_t *adb;
|
||||||
|
|
||||||
REQUIRE(handlep != NULL && DNS_ADBFIND_VALID(*handlep));
|
REQUIRE(findp != NULL && DNS_ADBFIND_VALID(*findp));
|
||||||
handle = *handlep;
|
find = *findp;
|
||||||
*handlep = NULL;
|
*findp = NULL;
|
||||||
|
|
||||||
LOCK(&handle->lock);
|
LOCK(&find->lock);
|
||||||
|
|
||||||
DP(("dns_adb_done on handle %p\n", handle));
|
DP(("dns_adb_done on find %p\n", find));
|
||||||
|
|
||||||
adb = handle->adb;
|
adb = find->adb;
|
||||||
REQUIRE(DNS_ADB_VALID(adb));
|
REQUIRE(DNS_ADB_VALID(adb));
|
||||||
|
|
||||||
REQUIRE(EVENT_FREED(handle));
|
REQUIRE(EVENT_FREED(find));
|
||||||
|
|
||||||
bucket = handle->name_bucket;
|
bucket = find->name_bucket;
|
||||||
INSIST(bucket == DNS_ADB_INVALIDBUCKET);
|
INSIST(bucket == DNS_ADB_INVALIDBUCKET);
|
||||||
|
|
||||||
UNLOCK(&handle->lock);
|
UNLOCK(&find->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The handle doesn't exist on any list, and nothing is locked.
|
* The find doesn't exist on any list, and nothing is locked.
|
||||||
* Return the handle to the memory pool, and decrement the adb's
|
* Return the find to the memory pool, and decrement the adb's
|
||||||
* reference count.
|
* reference count.
|
||||||
*/
|
*/
|
||||||
ai = ISC_LIST_HEAD(handle->list);
|
ai = ISC_LIST_HEAD(find->list);
|
||||||
while (ai != NULL) {
|
while (ai != NULL) {
|
||||||
ISC_LIST_UNLINK(handle->list, ai, publink);
|
ISC_LIST_UNLINK(find->list, ai, publink);
|
||||||
entry = ai->entry;
|
entry = ai->entry;
|
||||||
ai->entry = NULL;
|
ai->entry = NULL;
|
||||||
ai->sockaddr = NULL;
|
ai->sockaddr = NULL;
|
||||||
INSIST(DNS_ADBENTRY_VALID(entry));
|
INSIST(DNS_ADBENTRY_VALID(entry));
|
||||||
dec_entry_refcnt(adb, entry, ISC_TRUE);
|
dec_entry_refcnt(adb, entry, ISC_TRUE);
|
||||||
free_adbaddrinfo(adb, &ai);
|
free_adbaddrinfo(adb, &ai);
|
||||||
ai = ISC_LIST_HEAD(handle->list);
|
ai = ISC_LIST_HEAD(find->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WARNING: The handle is freed with the adb locked. This is done
|
* WARNING: The find is freed with the adb locked. This is done
|
||||||
* to avoid a race condition where we free the handle, some other
|
* to avoid a race condition where we free the find, some other
|
||||||
* thread tests to see if it should be destroyed, detects it should
|
* thread tests to see if it should be destroyed, detects it should
|
||||||
* be, destroys it, and then we try to lock it for our check, but the
|
* be, destroys it, and then we try to lock it for our check, but the
|
||||||
* lock is destroyed.
|
* lock is destroyed.
|
||||||
*/
|
*/
|
||||||
LOCK(&adb->lock);
|
LOCK(&adb->lock);
|
||||||
free_adbhandle(adb, &handle);
|
free_adbfind(adb, &find);
|
||||||
check_exit(adb);
|
check_exit(adb);
|
||||||
UNLOCK(&adb->lock);
|
UNLOCK(&adb->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_cancelfind(dns_adbfind_t *handle)
|
dns_adb_cancelfind(dns_adbfind_t *find)
|
||||||
{
|
{
|
||||||
isc_event_t *ev;
|
isc_event_t *ev;
|
||||||
isc_task_t *task;
|
isc_task_t *task;
|
||||||
dns_adb_t *adb;
|
dns_adb_t *adb;
|
||||||
int bucket;
|
int bucket;
|
||||||
|
|
||||||
LOCK(&handle->lock);
|
LOCK(&find->lock);
|
||||||
|
|
||||||
DP(("dns_adb_cancelfind on handle %p\n", handle));
|
DP(("dns_adb_cancelfind on find %p\n", find));
|
||||||
|
|
||||||
adb = handle->adb;
|
adb = find->adb;
|
||||||
REQUIRE(DNS_ADB_VALID(adb));
|
REQUIRE(DNS_ADB_VALID(adb));
|
||||||
|
|
||||||
REQUIRE(!EVENT_FREED(handle));
|
REQUIRE(!EVENT_FREED(find));
|
||||||
REQUIRE(WANTEVENT(handle->options));
|
REQUIRE(WANTEVENT(find->options));
|
||||||
|
|
||||||
bucket = handle->name_bucket;
|
bucket = find->name_bucket;
|
||||||
if (bucket == DNS_ADB_INVALIDBUCKET)
|
if (bucket == DNS_ADB_INVALIDBUCKET)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to get the adbname's lock to unlink the handle.
|
* We need to get the adbname's lock to unlink the find.
|
||||||
*/
|
*/
|
||||||
violate_locking_hierarchy(&handle->lock, &adb->namelocks[bucket]);
|
violate_locking_hierarchy(&find->lock, &adb->namelocks[bucket]);
|
||||||
bucket = handle->name_bucket;
|
bucket = find->name_bucket;
|
||||||
if (bucket != DNS_ADB_INVALIDBUCKET) {
|
if (bucket != DNS_ADB_INVALIDBUCKET) {
|
||||||
ISC_LIST_UNLINK(handle->adbname->handles, handle, plink);
|
ISC_LIST_UNLINK(find->adbname->finds, find, plink);
|
||||||
handle->adbname = NULL;
|
find->adbname = NULL;
|
||||||
handle->name_bucket = DNS_ADB_INVALIDBUCKET;
|
find->name_bucket = DNS_ADB_INVALIDBUCKET;
|
||||||
}
|
}
|
||||||
UNLOCK(&adb->namelocks[bucket]);
|
UNLOCK(&adb->namelocks[bucket]);
|
||||||
bucket = DNS_ADB_INVALIDBUCKET;
|
bucket = DNS_ADB_INVALIDBUCKET;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
if (!EVENT_SENT(handle)) {
|
if (!EVENT_SENT(find)) {
|
||||||
ev = &handle->event;
|
ev = &find->event;
|
||||||
task = ev->sender;
|
task = ev->sender;
|
||||||
ev->sender = handle;
|
ev->sender = find;
|
||||||
ev->type = DNS_EVENT_ADBCANCELED;
|
ev->type = DNS_EVENT_ADBCANCELED;
|
||||||
ev->destroy = event_free;
|
ev->destroy = event_free;
|
||||||
ev->destroy_arg = handle;
|
ev->destroy_arg = find;
|
||||||
|
|
||||||
DP(("Sending event %p to task %p for handle %p\n",
|
DP(("Sending event %p to task %p for find %p\n",
|
||||||
ev, task, handle));
|
ev, task, find));
|
||||||
|
|
||||||
isc_task_sendanddetach(&task, &ev);
|
isc_task_sendanddetach(&task, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK(&handle->lock);
|
UNLOCK(&find->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2040,7 +2040,7 @@ dump_adb(dns_adb_t *adb, FILE *f)
|
|||||||
const char *tmpp;
|
const char *tmpp;
|
||||||
|
|
||||||
fprintf(f, "ADB %p DUMP:\n", adb);
|
fprintf(f, "ADB %p DUMP:\n", adb);
|
||||||
fprintf(f, "erefcnt %u, irefcnt %u, handles out %u\n",
|
fprintf(f, "erefcnt %u, irefcnt %u, finds out %u\n",
|
||||||
adb->erefcnt, adb->irefcnt,
|
adb->erefcnt, adb->irefcnt,
|
||||||
isc_mempool_getallocated(adb->nhmp));
|
isc_mempool_getallocated(adb->nhmp));
|
||||||
|
|
||||||
@ -2068,7 +2068,7 @@ dump_adb(dns_adb_t *adb, FILE *f)
|
|||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
print_namehook_list(f, name);
|
print_namehook_list(f, name);
|
||||||
print_fetch_list(f, name);
|
print_fetch_list(f, name);
|
||||||
print_handle_list(f, name);
|
print_find_list(f, name);
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
name = ISC_LIST_NEXT(name, plink);
|
name = ISC_LIST_NEXT(name, plink);
|
||||||
@ -2129,7 +2129,7 @@ dump_adb(dns_adb_t *adb, FILE *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_dumphandle(dns_adbfind_t *handle, FILE *f)
|
dns_adb_dumpfind(dns_adbfind_t *find, FILE *f)
|
||||||
{
|
{
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
const char *tmpp;
|
const char *tmpp;
|
||||||
@ -2141,16 +2141,16 @@ dns_adb_dumphandle(dns_adbfind_t *handle, FILE *f)
|
|||||||
* want to dump out the name and/or entries too.
|
* want to dump out the name and/or entries too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LOCK(&handle->lock);
|
LOCK(&find->lock);
|
||||||
|
|
||||||
fprintf(f, "Handle %p\n", handle);
|
fprintf(f, "Find %p\n", find);
|
||||||
fprintf(f, "\tqpending %08x partial %08x options %08x\n",
|
fprintf(f, "\tqpending %08x partial %08x options %08x\n",
|
||||||
handle->query_pending, handle->partial_result,
|
find->query_pending, find->partial_result,
|
||||||
handle->options);
|
find->options);
|
||||||
fprintf(f, "\tname_bucket %d, name %p, event sender %p\n",
|
fprintf(f, "\tname_bucket %d, name %p, event sender %p\n",
|
||||||
handle->name_bucket, handle->adbname, handle->event.sender);
|
find->name_bucket, find->adbname, find->event.sender);
|
||||||
|
|
||||||
ai = ISC_LIST_HEAD(handle->list);
|
ai = ISC_LIST_HEAD(find->list);
|
||||||
if (ai != NULL)
|
if (ai != NULL)
|
||||||
fprintf(f, "\tAddresses:\n");
|
fprintf(f, "\tAddresses:\n");
|
||||||
while (ai != NULL) {
|
while (ai != NULL) {
|
||||||
@ -2178,7 +2178,7 @@ dns_adb_dumphandle(dns_adbfind_t *handle, FILE *f)
|
|||||||
ai = ISC_LIST_NEXT(ai, publink);
|
ai = ISC_LIST_NEXT(ai, publink);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK(&handle->lock);
|
UNLOCK(&find->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2221,19 +2221,19 @@ print_fetch_list(FILE *f, dns_adbname_t *n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_handle_list(FILE *f, dns_adbname_t *name)
|
print_find_list(FILE *f, dns_adbname_t *name)
|
||||||
{
|
{
|
||||||
dns_adbfind_t *handle;
|
dns_adbfind_t *find;
|
||||||
|
|
||||||
handle = ISC_LIST_HEAD(name->handles);
|
find = ISC_LIST_HEAD(name->finds);
|
||||||
while (handle != NULL) {
|
while (find != NULL) {
|
||||||
fprintf(f, "\t\tHandle %p\n", handle);
|
fprintf(f, "\t\tFind %p\n", find);
|
||||||
handle = ISC_LIST_NEXT(handle, plink);
|
find = ISC_LIST_NEXT(find, plink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On entry, "bucket" refers to a locked name bucket, "handle" is not NULL,
|
* On entry, "bucket" refers to a locked name bucket, "find" is not NULL,
|
||||||
* and "name" is the name we are looking for. We will allocate an adbname
|
* and "name" is the name we are looking for. We will allocate an adbname
|
||||||
* and return a pointer to it in *adbnamep.
|
* and return a pointer to it in *adbnamep.
|
||||||
*
|
*
|
||||||
@ -2242,7 +2242,7 @@ print_handle_list(FILE *f, dns_adbname_t *name)
|
|||||||
* perhaps some fetches have been started.
|
* perhaps some fetches have been started.
|
||||||
*/
|
*/
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
dbfind_name_v4(dns_adbfind_t *handle, dns_name_t *zone,
|
dbfind_name_v4(dns_adbfind_t *find, dns_name_t *zone,
|
||||||
dns_adbname_t *adbname, int bucket, isc_stdtime_t now)
|
dns_adbname_t *adbname, int bucket, isc_stdtime_t now)
|
||||||
{
|
{
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@ -2250,7 +2250,7 @@ dbfind_name_v4(dns_adbfind_t *handle, dns_name_t *zone,
|
|||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_adb_t *adb;
|
dns_adb_t *adb;
|
||||||
|
|
||||||
INSIST(DNS_ADBFIND_VALID(handle));
|
INSIST(DNS_ADBFIND_VALID(find));
|
||||||
INSIST(DNS_ADBNAME_VALID(adbname));
|
INSIST(DNS_ADBNAME_VALID(adbname));
|
||||||
adb = adbname->adb;
|
adb = adbname->adb;
|
||||||
INSIST(DNS_ADB_VALID(adb));
|
INSIST(DNS_ADB_VALID(adb));
|
||||||
@ -2272,7 +2272,13 @@ dbfind_name_v4(dns_adbfind_t *handle, dns_name_t *zone,
|
|||||||
case DNS_R_GLUE:
|
case DNS_R_GLUE:
|
||||||
case DNS_R_HINT:
|
case DNS_R_HINT:
|
||||||
case DNS_R_SUCCESS:
|
case DNS_R_SUCCESS:
|
||||||
result = import_rdatasetv4(adbname, &rdataset, now);
|
/*
|
||||||
|
* Found in the database. Even if we can't copy out
|
||||||
|
* any information, return success, or else a fetch
|
||||||
|
* will be made, which will only make things worse.
|
||||||
|
*/
|
||||||
|
(void)import_rdatasetv4(adbname, &rdataset, now);
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2354,7 +2360,7 @@ fetch_callback_v4(isc_task_t *task, isc_event_t *ev)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Did we get back junk? If so, and there are no more fetches
|
* Did we get back junk? If so, and there are no more fetches
|
||||||
* sitting out there, tell all the handles about it.
|
* sitting out there, tell all the finds about it.
|
||||||
*/
|
*/
|
||||||
if (dev->result != ISC_R_SUCCESS) {
|
if (dev->result != ISC_R_SUCCESS) {
|
||||||
ev_status = DNS_EVENT_ADBNOMOREADDRESSES;
|
ev_status = DNS_EVENT_ADBNOMOREADDRESSES;
|
||||||
@ -2377,7 +2383,7 @@ fetch_callback_v4(isc_task_t *task, isc_event_t *ev)
|
|||||||
isc_event_free(&ev);
|
isc_event_free(&ev);
|
||||||
|
|
||||||
if (EMPTY(name->fetches)) {
|
if (EMPTY(name->fetches)) {
|
||||||
clean_handles_at_name(name, ev_status);
|
clean_finds_at_name(name, ev_status);
|
||||||
name->query_pending &= ~DNS_ADBFIND_INET;
|
name->query_pending &= ~DNS_ADBFIND_INET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ typedef struct dns_adbname dns_adbname_t;
|
|||||||
|
|
||||||
/* dns_adbfind_t
|
/* dns_adbfind_t
|
||||||
*
|
*
|
||||||
* The handle into our internal state of what is going on, where, when...
|
* The find into our internal state of what is going on, where, when...
|
||||||
* This is returned to the user as a handle, so requests can be canceled,
|
* This is returned to the user as a find, so requests can be canceled,
|
||||||
* etc.
|
* etc.
|
||||||
*
|
*
|
||||||
* On return, the client can safely use "list", and can reorder the list.
|
* On return, the client can safely use "list", and can reorder the list.
|
||||||
@ -227,7 +227,7 @@ isc_result_t
|
|||||||
dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
||||||
void *arg, dns_name_t *name, dns_name_t *zone,
|
void *arg, dns_name_t *name, dns_name_t *zone,
|
||||||
unsigned int families, isc_stdtime_t now,
|
unsigned int families, isc_stdtime_t now,
|
||||||
dns_adbfind_t **handle);
|
dns_adbfind_t **find);
|
||||||
/*
|
/*
|
||||||
* Main interface for clients. The adb will look up the name given in
|
* Main interface for clients. The adb will look up the name given in
|
||||||
* "name" and will build up a list of found addresses, and perhaps start
|
* "name" and will build up a list of found addresses, and perhaps start
|
||||||
@ -262,7 +262,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|||||||
*
|
*
|
||||||
* zone != NULL and *zone be a valid dns_name_t.
|
* zone != NULL and *zone be a valid dns_name_t.
|
||||||
*
|
*
|
||||||
* handle != NULL && *handle == NULL.
|
* find != NULL && *find == NULL.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
*
|
*
|
||||||
@ -329,19 +329,19 @@ dns_adb_insert(dns_adb_t *adb, dns_name_t *host, isc_sockaddr_t *addr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_cancelfind(dns_adbfind_t *handle);
|
dns_adb_cancelfind(dns_adbfind_t *find);
|
||||||
/*
|
/*
|
||||||
* Cancels the find, and sends the event off to the caller.
|
* Cancels the find, and sends the event off to the caller.
|
||||||
*
|
*
|
||||||
* It is an error to call dns_adb_cancelfind() on a handle where
|
* It is an error to call dns_adb_cancelfind() on a find where
|
||||||
* no event is wanted, or will ever be sent.
|
* no event is wanted, or will ever be sent.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
* 'handle' be a valid dns_adbfind_t pointer.
|
* 'find' be a valid dns_adbfind_t pointer.
|
||||||
*
|
*
|
||||||
* events would have been posted to the task. This can be checked
|
* events would have been posted to the task. This can be checked
|
||||||
* with (handle->options & DNS_ADBFIND_WANTEVENT).
|
* with (find->options & DNS_ADBFIND_WANTEVENT).
|
||||||
*
|
*
|
||||||
* Ensures:
|
* Ensures:
|
||||||
*
|
*
|
||||||
@ -351,18 +351,18 @@ dns_adb_cancelfind(dns_adbfind_t *handle);
|
|||||||
*
|
*
|
||||||
* It is possible that the real completion event was posted just
|
* It is possible that the real completion event was posted just
|
||||||
* before the dns_adb_cancelfind() call was made. In this case,
|
* before the dns_adb_cancelfind() call was made. In this case,
|
||||||
* dns_adb_cancelfind() will do nothing. The event handler needs
|
* dns_adb_cancelfind() will do nothing. The event findr needs
|
||||||
* to be prepared to handle this situation.
|
* to be prepared to find this situation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_destroyfind(dns_adbfind_t **handle);
|
dns_adb_destroyfind(dns_adbfind_t **find);
|
||||||
/*
|
/*
|
||||||
* Destroys the handle reference.
|
* Destroys the find reference.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
* 'handle' != NULL and *handle be valid dns_adbfind_t pointer.
|
* 'find' != NULL and *find be valid dns_adbfind_t pointer.
|
||||||
*
|
*
|
||||||
* Ensures:
|
* Ensures:
|
||||||
*
|
*
|
||||||
@ -372,7 +372,7 @@ dns_adb_destroyfind(dns_adbfind_t **handle);
|
|||||||
* Note:
|
* Note:
|
||||||
*
|
*
|
||||||
* This can only be called after the event was delivered for a
|
* This can only be called after the event was delivered for a
|
||||||
* handle. Additionally, the event MUST have been freed via
|
* find. Additionally, the event MUST have been freed via
|
||||||
* isc_event_free() BEFORE this function is called.
|
* isc_event_free() BEFORE this function is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -390,15 +390,15 @@ dns_adb_dump(dns_adb_t *adb, FILE *f);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_adb_dumphandle(dns_adbfind_t *handle, FILE *f);
|
dns_adb_dumpfind(dns_adbfind_t *find, FILE *f);
|
||||||
/*
|
/*
|
||||||
* Dump the data associated with a handle.
|
* Dump the data associated with a find.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
* adb be valid.
|
* adb be valid.
|
||||||
*
|
*
|
||||||
* adbhandle be valid.
|
* adbfind be valid.
|
||||||
*
|
*
|
||||||
* f != NULL, and be a file open for writing.
|
* f != NULL, and be a file open for writing.
|
||||||
*/
|
*/
|
||||||
@ -473,7 +473,7 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
|
|||||||
/*
|
/*
|
||||||
* XXX Need functions/macros to:
|
* XXX Need functions/macros to:
|
||||||
*
|
*
|
||||||
* Remove an address from a handle's linked list. This is needed
|
* Remove an address from a find's linked list. This is needed
|
||||||
* because the data pointed to by a dns_adbaddr_t is reference counted.
|
* because the data pointed to by a dns_adbaddr_t is reference counted.
|
||||||
*
|
*
|
||||||
* set/clear various flags. (Which flags?)
|
* set/clear various flags. (Which flags?)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user