diff --git a/bin/lwresd/main.c b/bin/lwresd/main.c index a68e876e4c..9af83d81ab 100644 --- a/bin/lwresd/main.c +++ b/bin/lwresd/main.c @@ -213,7 +213,8 @@ parse_resolv_conf(isc_mem_t *mem) { int i; lwctx = NULL; - lwresult = lwres_context_create(&lwctx, mem, mem_alloc, mem_free); + lwresult = lwres_context_create(&lwctx, mem, mem_alloc, mem_free, + LWRES_CONTEXT_SERVERMODE); if (lwresult != LWRES_R_SUCCESS) return; @@ -404,7 +405,8 @@ main(int argc, char **argv) { cmgr[i].mctx = mem; cmgr[i].lwctx = NULL; result = lwres_context_create(&cmgr[i].lwctx, mem, - mem_alloc, mem_free); + mem_alloc, mem_free, + LWRES_CONTEXT_SERVERMODE); if (result != ISC_R_SUCCESS) { isc_task_detach(&cmgr[i].task); break; diff --git a/bin/tests/lwres_test.c b/bin/tests/lwres_test.c index 222a48ebc3..16f8a6ea71 100644 --- a/bin/tests/lwres_test.c +++ b/bin/tests/lwres_test.c @@ -257,9 +257,9 @@ main(int argc, char *argv[]) { ctx = NULL; #ifdef USE_ISC_MEM - ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free); + ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free, 0); #else - ret = lwres_context_create(&ctx, NULL, NULL, NULL); + ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0); #endif CHECK(ret, "lwres_context_create"); diff --git a/bin/tests/lwresconf_test.c b/bin/tests/lwresconf_test.c index f39356411c..980395adf5 100644 --- a/bin/tests/lwresconf_test.c +++ b/bin/tests/lwresconf_test.c @@ -71,9 +71,9 @@ main(int argc, char *argv[]) { ctx = NULL; #ifdef USE_ISC_MEM - ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free); + ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free, 0); #else - ret = lwres_context_create(&ctx, NULL, NULL, NULL); + ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0); #endif CHECK(ret, "lwres_context_create"); diff --git a/lib/lwres/context.c b/lib/lwres/context.c index c87f25fdb2..c2643352d3 100644 --- a/lib/lwres/context.c +++ b/lib/lwres/context.c @@ -55,7 +55,8 @@ context_connect(lwres_context_t *); lwres_result_t lwres_context_create(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, - lwres_free_t free_function) + lwres_free_t free_function, + unsigned int flags) { lwres_context_t *ctx; @@ -87,7 +88,8 @@ lwres_context_create(lwres_context_t **contextp, void *arg, ctx->timeout = LWRES_DEFAULT_TIMEOUT; ctx->serial = (lwres_uint32_t)ctx; /* XXXMLG */ - (void)context_connect(ctx); /* XXXMLG */ + if ((flags & LWRES_CONTEXT_SERVERMODE) == 0) + (void)context_connect(ctx); /* XXXMLG */ /* * Init resolv.conf bits. diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 92e360f7de..37fc85e985 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -3,7 +3,7 @@ * The Berkeley Software Design Inc. software License Agreement specifies * the terms and conditions for redistribution. * - * BSDI $Id: getaddrinfo.c,v 1.21 2000/06/15 21:52:21 explorer Exp $ + * BSDI $Id: getaddrinfo.c,v 1.22 2000/06/15 23:48:07 explorer Exp $ */ #include @@ -417,7 +417,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, lwres_result_t lwres; int result = 0; - lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL); + lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (lwres != 0) ERR(EAI_FAIL); if (hostname == NULL && (flags & AI_PASSIVE) == 0) { @@ -470,7 +470,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, lwres_result_t lwres; int result = 0; - lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL); + lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (lwres != 0) ERR(EAI_FAIL); diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 504bd5f582..14932fed17 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -159,7 +159,7 @@ lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) { return (copyandmerge(&he, NULL, af, error_num)); } - n = lwres_context_create(&lwrctx, NULL, NULL, NULL); + n = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (n != 0) { *error_num = NO_RECOVERY; goto cleanup; @@ -269,7 +269,7 @@ lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { if (af == AF_INET6) cp += 12; - n = lwres_context_create(&lwrctx, NULL, NULL, NULL); + n = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (n == 0) n = lwres_getnamebyaddr(lwrctx, LWRES_ADDRTYPE_V4, INADDRSZ, cp, &by); @@ -306,7 +306,7 @@ lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { return (NULL); } - n = lwres_context_create(&lwrctx, NULL, NULL, NULL); + n = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (n == 0) n = lwres_getnamebyaddr(lwrctx, LWRES_ADDRTYPE_V6, IN6ADDRSZ, src, &by); diff --git a/lib/lwres/getnameinfo.c b/lib/lwres/getnameinfo.c index bf6474b3a9..b493a603ee 100644 --- a/lib/lwres/getnameinfo.c +++ b/lib/lwres/getnameinfo.c @@ -227,7 +227,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, INSIST(0); } - n = lwres_context_create(&lwrctx, NULL, NULL, NULL); + n = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); if (n == 0) n = lwres_getnamebyaddr(lwrctx, lwf, afd->a_addrlen, addr, &by); diff --git a/lib/lwres/include/lwres/context.h b/lib/lwres/include/lwres/context.h index 78f44cda3e..e5a01a3670 100644 --- a/lib/lwres/include/lwres/context.h +++ b/lib/lwres/include/lwres/context.h @@ -49,10 +49,18 @@ typedef void (*lwres_free_t)(void *arg, void *mem, size_t length); * Share /etc/resolv.conf data between contexts. */ +/* + * _SERVERMODE + * Don't allocate and connect a socket to the server, since the + * caller _is_ a server. + */ +#define LWRES_CONTEXT_SERVERMODE 0x00000001U + lwres_result_t lwres_context_create(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, - lwres_free_t free_function); + lwres_free_t free_function, + unsigned int flags); /* * Allocate a lwres context. This is used in all lwres calls. *