diff --git a/bin/dig/dig.c b/bin/dig/dig.c index e5ce17011c..f4f95c9e40 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dig.c,v 1.52 2000/06/28 18:20:41 mws Exp $ */ +/* $Id: dig.c,v 1.53 2000/06/29 05:21:08 mws Exp $ */ #include #include @@ -169,6 +169,7 @@ show_usage(void) { void dighost_shutdown(void) { + free_lists(0); isc_app_shutdown(); } @@ -1220,7 +1221,11 @@ main(int argc, char **argv) { setup_system(); start_lookup(); isc_app_run(); - free_lists(0); + if (isc_mem_debugging) + isc_mem_stats(mctx, stderr); + isc_app_finish(); + if (mctx != NULL) + isc_mem_destroy(&mctx); return (exitcode); } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index a6cca42b4a..cdef4090ec 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dighost.c,v 1.61 2000/06/28 18:20:43 mws Exp $ */ +/* $Id: dighost.c,v 1.62 2000/06/29 05:21:10 mws Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -1999,9 +1999,11 @@ free_lists(int _exitcode) { l = ISC_LIST_HEAD(lookup_list); while (l != NULL) { + if (l->timer != NULL) + isc_timer_detach (&l->timer); q = ISC_LIST_HEAD(l->q); while (q != NULL) { - debug ("Freeing query %lx, belonging to %lx", + debug ("Cancelling query %lx, belonging to %lx", q, l); if (q->sock != NULL) { isc_socket_cancel(q->sock, NULL, @@ -2010,41 +2012,9 @@ free_lists(int _exitcode) { sockcount--; debug ("Socket = %d",sockcount); } - if (ISC_LINK_LINKED(&q->recvbuf, link)) - ISC_LIST_DEQUEUE(q->recvlist, &q->recvbuf, - link); - if (ISC_LINK_LINKED(&q->lengthbuf, link)) - ISC_LIST_DEQUEUE(q->lengthlist, &q->lengthbuf, - link); - isc_buffer_invalidate(&q->recvbuf); - isc_buffer_invalidate(&q->lengthbuf); - ptr = q; q = ISC_LIST_NEXT(q, link); - isc_mem_free(mctx, ptr); } - if (l->use_my_server_list) { - s = ISC_LIST_HEAD(l->my_server_list); - while (s != NULL) { - debug ("Freeing server %lx belonging to %lx", - s, l); - ptr = s; - s = ISC_LIST_NEXT(s, link); - isc_mem_free(mctx, ptr); - - } - } - if (l->sendmsg != NULL) - dns_message_destroy (&l->sendmsg); - if (l->timer != NULL) - isc_timer_detach (&l->timer); - if (l->querysig != NULL) { - debug ("Freeing buffer %lx", l->querysig); - isc_buffer_free(&l->querysig); - } - - ptr = l; l = ISC_LIST_NEXT(l, link); - isc_mem_free(mctx, ptr); } s = ISC_LIST_HEAD(server_list); while (s != NULL) { @@ -2098,11 +2068,46 @@ free_lists(int _exitcode) { isc_entropy_detach(&entp); } - if (isc_mem_debugging) - isc_mem_stats(mctx, stderr); - isc_app_finish(); - if (mctx != NULL) - isc_mem_destroy(&mctx); + l = ISC_LIST_HEAD(lookup_list); + while (l != NULL) { + q = ISC_LIST_HEAD(l->q); + while (q != NULL) { + debug ("Freeing query %lx, belonging to %lx", + q, l); + if (ISC_LINK_LINKED(&q->recvbuf, link)) + ISC_LIST_DEQUEUE(q->recvlist, &q->recvbuf, + link); + if (ISC_LINK_LINKED(&q->lengthbuf, link)) + ISC_LIST_DEQUEUE(q->lengthlist, &q->lengthbuf, + link); + isc_buffer_invalidate(&q->recvbuf); + isc_buffer_invalidate(&q->lengthbuf); + ptr = q; + q = ISC_LIST_NEXT(q, link); + isc_mem_free(mctx, ptr); + } + if (l->use_my_server_list) { + s = ISC_LIST_HEAD(l->my_server_list); + while (s != NULL) { + debug ("Freeing server %lx belonging to %lx", + s, l); + ptr = s; + s = ISC_LIST_NEXT(s, link); + isc_mem_free(mctx, ptr); + + } + } + if (l->sendmsg != NULL) + dns_message_destroy (&l->sendmsg); + if (l->querysig != NULL) { + debug ("Freeing buffer %lx", l->querysig); + isc_buffer_free(&l->querysig); + } + + ptr = l; + l = ISC_LIST_NEXT(l, link); + isc_mem_free(mctx, ptr); + } debug("Getting ready to exit, code=%d",_exitcode); if (_exitcode != 0) diff --git a/bin/dig/host.c b/bin/dig/host.c index 07dadd1acf..29594713d6 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: host.c,v 1.30 2000/06/28 18:20:44 mws Exp $ */ +/* $Id: host.c,v 1.31 2000/06/29 05:21:11 mws Exp $ */ #include #include @@ -224,6 +224,7 @@ show_usage(void) { void dighost_shutdown(void) { + free_lists(0); isc_app_shutdown(); } @@ -695,7 +696,11 @@ main(int argc, char **argv) { setup_system(); start_lookup(); isc_app_run(); - free_lists(0); + if (isc_mem_debugging) + isc_mem_stats(mctx, stderr); + isc_app_finish(); + if (mctx != NULL) + isc_mem_destroy(&mctx); return (0); } diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 575b4293cd..b459a9914a 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: nslookup.c,v 1.20 2000/06/21 17:48:30 mws Exp $ */ +/* $Id: nslookup.c,v 1.21 2000/06/29 05:21:12 mws Exp $ */ #include @@ -875,6 +875,11 @@ main(int argc, char **argv) { free_lists(0); isc_mutex_destroy(&lock); isc_condition_destroy(&cond); + if (isc_mem_debugging) + isc_mem_stats(mctx, stderr); + isc_app_finish(); + if (mctx != NULL) + isc_mem_destroy(&mctx); return (0); }