From: Mark Andrews Date: Thu, 7 Dec 2006 01:36:50 +0000 (+0000) Subject: 2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] X-Git-Tag: v9.2.7~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b24244e2b7ff3e9696119752025b77f25569bf0c;p=thirdparty%2Fbind9.git 2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] --- diff --git a/CHANGES b/CHANGES index 04dc88593f6..fa7f182f1a4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ --- 9.2.7 released --- +2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] + 2103. [port] Add /usr/sfw to list of locations for OpenSSL under Solaris. diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c65f4a53777..822fde6b85b 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.221.2.33 2006/10/02 03:14:14 marka Exp $ */ +/* $Id: dighost.c,v 1.221.2.34 2006/12/07 01:36:49 marka Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -428,8 +428,6 @@ make_empty_lookup(void) { fatal("Memory allocation failure in %s:%d", __FILE__, __LINE__); looknew->pending = ISC_TRUE; - looknew->waiting_senddone = ISC_FALSE; - looknew->pending_clear = ISC_FALSE; looknew->textname[0] = 0; looknew->cmdline[0] = 0; looknew->rdtype = dns_rdatatype_a; @@ -930,7 +928,7 @@ clear_query(dig_query_t *query) { isc_mempool_put(commctx, query->recvspace); isc_buffer_invalidate(&query->recvbuf); isc_buffer_invalidate(&query->lengthbuf); - if (lookup->waiting_senddone) + if (query->waiting_senddone) query->pending_free = ISC_TRUE; else isc_mem_free(mctx, query); @@ -963,11 +961,6 @@ try_clear_lookup(dig_lookup_t *lookup) { return (ISC_FALSE); } - if (lookup->waiting_senddone) { - lookup->pending_clear = ISC_TRUE; - return (ISC_TRUE); - } - /* * At this point, we know there are no queries on the lookup, * so can make it go away also. @@ -1450,9 +1443,9 @@ setup_lookup(dig_lookup_t *lookup) { check_result(result, "dns_compress_init"); debug("starting to render the message"); - isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE); + isc_buffer_init(&lookup->renderbuf, lookup->sendspace, COMMSIZE); result = dns_message_renderbegin(lookup->sendmsg, &cctx, - &lookup->sendbuf); + &lookup->renderbuf); check_result(result, "dns_message_renderbegin"); if (lookup->udpsize > 0 || lookup->dnssec) { if (lookup->udpsize == 0) @@ -1475,7 +1468,7 @@ setup_lookup(dig_lookup_t *lookup) { /* * Force TCP mode if the request is larger than 512 bytes. */ - if (isc_buffer_usedlength(&lookup->sendbuf) > 512) + if (isc_buffer_usedlength(&lookup->renderbuf) > 512) lookup->tcp_mode = ISC_TRUE; lookup->pending = ISC_FALSE; @@ -1491,6 +1484,7 @@ setup_lookup(dig_lookup_t *lookup) { query, lookup); query->lookup = lookup; query->waiting_connect = ISC_FALSE; + query->waiting_senddone = ISC_FALSE; query->pending_free = ISC_FALSE; query->recv_made = ISC_FALSE; query->first_pass = ISC_TRUE; @@ -1514,6 +1508,7 @@ setup_lookup(dig_lookup_t *lookup) { isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE); isc_buffer_init(&query->lengthbuf, query->lengthspace, 2); isc_buffer_init(&query->slbuf, query->slspace, 2); + query->sendbuf = lookup->renderbuf; ISC_LINK_INIT(query, link); ISC_LIST_ENQUEUE(lookup->q, query, link); @@ -1553,8 +1548,8 @@ send_done(isc_task_t *_task, isc_event_t *event) { ISC_LIST_DEQUEUE(sevent->bufferlist, b, link); query = event->ev_arg; + query->waiting_senddone = ISC_FALSE; l = query->lookup; - l->waiting_senddone = ISC_FALSE; if (l->ns_search_only && !l->trace_root) { debug("sending next, since searching"); @@ -1567,8 +1562,6 @@ send_done(isc_task_t *_task, isc_event_t *event) { if (query->pending_free) isc_mem_free(mctx, query); - if (l->pending_clear) - try_clear_lookup(l); check_if_done(); UNLOCK_LOOKUP; @@ -1762,14 +1755,12 @@ send_udp(dig_query_t *query) { debug("recvcount=%d", recvcount); } ISC_LIST_INIT(query->sendlist); - ISC_LINK_INIT(&l->sendbuf, link); - ISC_LIST_ENQUEUE(query->sendlist, &l->sendbuf, - link); + ISC_LIST_ENQUEUE(query->sendlist, &query->sendbuf, link); debug("sending a request"); result = isc_time_now(&query->time_sent); check_result(result, "isc_time_now"); INSIST(query->sock != NULL); - l->waiting_senddone = ISC_TRUE; + query->waiting_senddone = ISC_TRUE; result = isc_socket_sendtov(query->sock, &query->sendlist, global_task, send_done, query, &query->sockaddr, NULL); @@ -1949,15 +1940,12 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) { isc_buffer_clear(&query->slbuf); isc_buffer_clear(&query->lengthbuf); - isc_buffer_putuint16(&query->slbuf, (isc_uint16_t) query->lookup->sendbuf.used); + isc_buffer_putuint16(&query->slbuf, (isc_uint16_t) query->sendbuf.used); ISC_LIST_INIT(query->sendlist); ISC_LINK_INIT(&query->slbuf, link); ISC_LIST_ENQUEUE(query->sendlist, &query->slbuf, link); - if (include_question) { - ISC_LINK_INIT(&query->lookup->sendbuf, link); - ISC_LIST_ENQUEUE(query->sendlist, &query->lookup->sendbuf, - link); - } + if (include_question) + ISC_LIST_ENQUEUE(query->sendlist, &query->sendbuf, link); ISC_LINK_INIT(&query->lengthbuf, link); ISC_LIST_ENQUEUE(query->lengthlist, &query->lengthbuf, link); @@ -1968,9 +1956,9 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) { debug("recvcount=%d",recvcount); if (!query->first_soa_rcvd) { debug("sending a request in launch_next_query"); - query->lookup->waiting_senddone = ISC_TRUE; result = isc_time_now(&query->time_sent); check_result(result, "isc_time_now"); + query->waiting_senddone = ISC_TRUE; result = isc_socket_sendv(query->sock, &query->sendlist, global_task, send_done, query); check_result(result, "isc_socket_sendv"); diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index 7f1b26d4e6e..b53922523e6 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.h,v 1.71.2.14 2006/10/03 23:50:49 marka Exp $ */ +/* $Id: dig.h,v 1.71.2.15 2006/12/07 01:36:50 marka Exp $ */ #ifndef DIG_H #define DIG_H @@ -77,8 +77,6 @@ typedef struct dig_searchlist dig_searchlist_t; struct dig_lookup { isc_boolean_t pending, /* Pending a successful answer */ - waiting_senddone, - pending_clear, waiting_connect, doing_xfr, ns_search_only, /* dig +nssearch, host -C */ @@ -115,7 +113,7 @@ struct dig_lookup { char onamespace[BUFSIZE]; isc_buffer_t namebuf; isc_buffer_t onamebuf; - isc_buffer_t sendbuf; + isc_buffer_t renderbuf; char *sendspace; dns_name_t *name; isc_timer_t *timer; @@ -143,6 +141,7 @@ struct dig_query { dig_lookup_t *lookup; isc_boolean_t waiting_connect, pending_free, + waiting_senddone, first_pass, first_soa_rcvd, second_rr_rcvd, @@ -167,6 +166,7 @@ struct dig_query { ISC_LINK(dig_query_t) link; isc_sockaddr_t sockaddr; isc_time_t time_sent; + isc_buffer_t sendbuf; }; struct dig_server {