From: Mark Andrews Date: Thu, 7 Dec 2006 01:26:33 +0000 (+0000) Subject: 2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] X-Git-Tag: v9.3.4~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf9f31b18bc5975628eacce7e14ce73b48f18adc;p=thirdparty%2Fbind9.git 2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] --- diff --git a/CHANGES b/CHANGES index a1fef74fc1a..f4b36d9204e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ --- 9.3.3 released --- +2107. [bug] dighost.c: more cleanup of buffers. [RT #16499] + 2104. [port] Fix Solaris SMF error message. 2103. [port] Add /usr/sfw to list of locations for OpenSSL diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 68273679ccc..398711d4f1c 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.19.2.35 2006/10/02 03:14:24 marka Exp $ */ +/* $Id: dighost.c,v 1.221.2.19.2.36 2006/12/07 01:26:33 marka Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -667,8 +667,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; @@ -1198,7 +1196,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); @@ -1230,11 +1228,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. @@ -1796,9 +1789,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) @@ -1821,7 +1814,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; @@ -1837,6 +1830,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; @@ -1861,6 +1855,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); @@ -1900,8 +1895,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"); @@ -1914,8 +1909,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; @@ -2101,13 +2094,11 @@ 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"); TIME_NOW(&query->time_sent); 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); @@ -2286,16 +2277,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); @@ -2307,7 +2294,7 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) { if (!query->first_soa_rcvd) { debug("sending a request in launch_next_query"); TIME_NOW(&query->time_sent); - query->lookup->waiting_senddone = ISC_TRUE; + 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 100095871aa..91dae5cf2e2 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.6.2.13 2006/10/03 23:50:50 marka Exp $ */ +/* $Id: dig.h,v 1.71.2.6.2.14 2006/12/07 01:26:33 marka Exp $ */ #ifndef DIG_H #define DIG_H @@ -93,8 +93,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 */ @@ -148,7 +146,7 @@ isc_boolean_t sigchase; 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; @@ -176,6 +174,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, @@ -201,6 +200,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 {