From 427f933eceba2dd1022fa3b680ca1bd08cbce990 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Wed, 17 Jan 2001 00:48:19 +0000 Subject: [PATCH] use isc_app_block instead of an ugly hack. --- bin/dig/dighost.c | 35 ++++++----------------------------- bin/dig/nslookup.c | 8 ++++---- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c09ab4a3af..0b62666e3a 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.183 2001/01/16 23:15:54 bwelling Exp $ */ +/* $Id: dighost.c,v 1.184 2001/01/17 00:48:18 bwelling Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -83,8 +83,7 @@ isc_boolean_t usesearch = ISC_FALSE, qr = ISC_FALSE, is_dst_up = ISC_FALSE, - have_domain = ISC_FALSE, - is_blocking = ISC_FALSE; + have_domain = ISC_FALSE; in_port_t port = 53; unsigned int timeout = 0; @@ -2627,9 +2626,9 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { else { #if defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO) debug ("before getaddrinfo()"); - is_blocking = ISC_TRUE; + isc_app_block(); result = getaddrinfo(host, NULL, NULL, &res); - is_blocking = ISC_FALSE; + isc_app_unblock(); if (result != 0) { fatal("Couldn't find server '%s': %s", host, gai_strerror(result)); @@ -2640,9 +2639,9 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { freeaddrinfo(res); #else debug ("before gethostbyname()"); - is_blocking = ISC_TRUE; + isc_app_block(); he = gethostbyname(host); - is_blocking = ISC_FALSE; + isc_app_unblock(); if (he == NULL) fatal("Couldn't find server '%s' (h_errno=%d)", host, h_errno); @@ -2694,17 +2693,6 @@ cancel_all(void) { debug("cancel_all()"); - if (is_blocking) { - /* - * If we get here while another thread is blocking, there's - * really nothing we can do to make a clean shutdown - * without waiting for the block to complete. The only - * way to get the system down now is to just exit out, - * and trust the OS to clean up for us. - */ - fputs("Abort.\n", stderr); - exit(1); - } LOCK_LOOKUP; if (free_now) { UNLOCK_LOOKUP; @@ -2749,17 +2737,6 @@ destroy_libs(void) { dig_searchlist_t *o; debug("destroy_libs()"); - if (is_blocking) { - /* - * If we get here while another thread is blocking, there's - * really nothing we can do to make a clean shutdown - * without waiting for the block to complete. The only - * way to get the system down now is to just exit out, - * and trust the OS to clean up for us. - */ - fputs("Abort.\n", stderr); - exit(1); - } if (global_task != NULL) { debug("freeing task"); isc_task_detach(&global_task); diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 9c5525a4da..ff982f438a 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nslookup.c,v 1.75 2001/01/16 23:15:55 bwelling Exp $ */ +/* $Id: nslookup.c,v 1.76 2001/01/17 00:48:19 bwelling Exp $ */ #include @@ -50,7 +50,7 @@ extern ISC_LIST(dig_server_t) server_list; extern ISC_LIST(dig_searchlist_t) search_list; extern isc_boolean_t have_ipv6, - usesearch, trace, qr, debugging, is_blocking; + usesearch, trace, qr, debugging; extern in_port_t port; extern unsigned int timeout; extern isc_mem_t *mctx; @@ -740,9 +740,9 @@ get_next_command(void) { if (buf == NULL) fatal("Memory allocation failure."); fputs("> ", stderr); - is_blocking = ISC_TRUE; + isc_app_block(); ptr = fgets(buf, COMMSIZE, stdin); - is_blocking = ISC_FALSE; + isc_app_unblock(); if (ptr == NULL) { in_use = ISC_FALSE; goto cleanup;