From 6331b9a45efba4e4e71e66ce4e2613a3433d18b2 Mon Sep 17 00:00:00 2001 From: Michael Sawyer Date: Tue, 11 Jul 2000 17:35:49 +0000 Subject: [PATCH] Don't try and reset timers which aren't being used. --- bin/dig/dig.c | 9 ++++++++- bin/dig/dighost.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index f8f1183420..fd60e1fead 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dig.c,v 1.57 2000/07/10 18:02:27 bwelling Exp $ */ +/* $Id: dig.c,v 1.58 2000/07/11 17:35:48 mws Exp $ */ #include #include @@ -644,6 +644,13 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { timeout = atoi(&rv[0][6]); if (timeout <= 0) timeout = 1; + debug ("timeout set to %d", timeout); + } else if (strncmp(rv[0], "+timeout=", 9) == 0) { + /* Global option always */ + timeout = atoi(&rv[0][9]); + if (timeout <= 0) + timeout = 1; + debug ("timeout set to %d", timeout); } else if (strncmp(rv[0], "+tries=", 7) == 0) { if (have_host) { lookup->retries = atoi(&rv[0][7]); diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index fe8f0399a7..c7d96458b8 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dighost.c,v 1.73 2000/07/10 18:02:28 bwelling Exp $ */ +/* $Id: dighost.c,v 1.74 2000/07/11 17:35:49 mws Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -1193,6 +1193,7 @@ send_udp(dig_lookup_t *lookup) { local_timeout = UDP_TIMEOUT; } else local_timeout = timeout; + debug ("have local timeout of %d", local_timeout); isc_interval_set(&lookup->interval, local_timeout, 0); result = isc_timer_create(timermgr, isc_timertype_once, NULL, &lookup->interval, global_task, @@ -1763,19 +1764,21 @@ recv_done(isc_task_t *task, isc_event_t *event) { * the timeout to much longer, so brief network * outages won't cause the XFR to abort */ - if (timeout != INT_MAX) { + if ((timeout != INT_MAX) && + (query->lookup->timer != NULL)) { if (timeout == 0) { if (query->lookup->tcp_mode) local_timeout = TCP_TIMEOUT; else local_timeout = UDP_TIMEOUT; } else { - if (((long)timeout * 4) < - (long)INT_MAX) + if (timeout < (INT_MAX / 4)) local_timeout = timeout * 4; else local_timeout = INT_MAX; } + debug ("have local timeout of %d", + local_timeout); isc_interval_set(&query->lookup->interval, local_timeout, 0); result = isc_timer_reset(query->lookup->timer, @@ -1953,6 +1956,7 @@ do_lookup_tcp(dig_lookup_t *lookup) { local_timeout = UDP_TIMEOUT; } else local_timeout = timeout; + debug ("have local timeout of %d", local_timeout); isc_interval_set(&lookup->interval, local_timeout, 0); result = isc_timer_create(timermgr, isc_timertype_once, NULL, &lookup->interval, global_task,