mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 12:50:00 -04:00
detach from dispatches and dispatch manager; use dns_name_format() and
isc_netaddr_format(); assign a name to the task; turn off memory debugging
This commit is contained in:
parent
f34984369f
commit
bfa633fc0e
1 changed files with 17 additions and 31 deletions
|
|
@ -19,15 +19,13 @@
|
|||
* Principal Author: Bob Halley
|
||||
*/
|
||||
|
||||
/* XXXRTH */
|
||||
#define ISC_MEM_DEBUG 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/app.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
|
@ -41,6 +39,7 @@
|
|||
#include <dns/result.h>
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_taskmgr_t *taskmgr;
|
||||
static dns_view_t *view = NULL;
|
||||
static dns_adbfind_t *find = NULL;
|
||||
static isc_task_t *task = NULL;
|
||||
|
|
@ -86,43 +85,24 @@ log_init(void) {
|
|||
static void
|
||||
print_addresses(dns_adbfind_t *find) {
|
||||
dns_adbaddrinfo_t *address;
|
||||
isc_result_t result;
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
char text[1024];
|
||||
|
||||
isc_buffer_init(&b, text, sizeof(text));
|
||||
|
||||
for (address = ISC_LIST_HEAD(find->list);
|
||||
address != NULL;
|
||||
address = ISC_LIST_NEXT(address, publink)) {
|
||||
isc_buffer_clear(&b);
|
||||
result = isc_sockaddr_totext(address->sockaddr, &b);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(&b, &r);
|
||||
printf("%.*s\n", (int)r.length, r.base);
|
||||
} else
|
||||
printf("isc_sockaddr_totext() failed: %s\n",
|
||||
isc_result_totext(result));
|
||||
isc_netaddr_t netaddr;
|
||||
char text[ISC_NETADDR_FORMATSIZE];
|
||||
isc_netaddr_fromsockaddr(&netaddr, address->sockaddr);
|
||||
isc_netaddr_format(&netaddr, text, sizeof(text));
|
||||
printf("%s\n", text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_name(dns_name_t *name) {
|
||||
isc_result_t result;
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
char text[1024];
|
||||
|
||||
isc_buffer_init(&b, text, sizeof(text));
|
||||
|
||||
result = dns_name_totext(name, ISC_FALSE, &b);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(&b, &r);
|
||||
printf("%.*s\n", (int)r.length, r.base);
|
||||
} else
|
||||
printf("dns_name_totext() failed: %s\n",
|
||||
isc_result_totext(result));
|
||||
dns_name_format(name, text, sizeof(text));
|
||||
printf("%s\n", text);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -213,7 +193,6 @@ int
|
|||
main(int argc, char *argv[]) {
|
||||
isc_boolean_t verbose = ISC_FALSE;
|
||||
unsigned int workers = 2;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
isc_timermgr_t *timermgr;
|
||||
int ch;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
|
|
@ -256,6 +235,7 @@ main(int argc, char *argv[]) {
|
|||
task = NULL;
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_task_setname(task, "byname", NULL);
|
||||
|
||||
dispatchmgr = NULL;
|
||||
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr)
|
||||
|
|
@ -306,6 +286,9 @@ main(int argc, char *argv[]) {
|
|||
dispatchmgr,
|
||||
disp4, disp6) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
dns_dispatch_detach(&disp4);
|
||||
dns_dispatch_detach(&disp6);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -344,11 +327,14 @@ main(int argc, char *argv[]) {
|
|||
dns_view_detach(&view);
|
||||
isc_task_shutdown(task);
|
||||
isc_task_detach(&task);
|
||||
|
||||
dns_dispatchmgr_destroy(&dispatchmgr);
|
||||
|
||||
isc_taskmgr_destroy(&taskmgr);
|
||||
|
||||
isc_socketmgr_destroy(&socketmgr);
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
if (verbose)
|
||||
|
|
|
|||
Loading…
Reference in a new issue