diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index cb4557670d..301cde1cd5 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.194 2001/02/24 20:53:26 bwelling Exp $ */ +/* $Id: dighost.c,v 1.195 2001/03/05 21:15:32 bwelling Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -1264,6 +1264,7 @@ setup_lookup(dig_lookup_t *lookup) { dig_query_t *query; isc_region_t r; isc_buffer_t b; + dns_compress_t cctx; char store[MXNAME]; REQUIRE(lookup != NULL); @@ -1439,9 +1440,13 @@ setup_lookup(dig_lookup_t *lookup) { if (lookup->sendspace == NULL) fatal("memory allocation failure"); + result = dns_compress_init(&cctx, -1, mctx); + check_result(result, "dns_compress_init"); + debug("starting to render the message"); isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE); - result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf); + result = dns_message_renderbegin(lookup->sendmsg, &cctx, + &lookup->sendbuf); check_result(result, "dns_message_renderbegin"); #ifndef DNS_OPT_NEWCODES_LIVE if (lookup->udpsize > 0 || lookup->dnssec) { @@ -1450,7 +1455,7 @@ setup_lookup(dig_lookup_t *lookup) { lookup->zonename[0] != 0 || lookup->viewname[0] != 0) { dns_fixedname_t fname; isc_buffer_t namebuf, *wirebuf = NULL; - dns_compress_t cctx; + dns_compress_t zcctx; dns_optlist_t optlist; dns_optattr_t optattr[2]; #endif /* DNS_OPT_NEWCODES_LIVE */ @@ -1474,12 +1479,12 @@ setup_lookup(dig_lookup_t *lookup) { dns_rootname, ISC_FALSE, NULL); check_result(result, "; illegal zone option"); - result = dns_compress_init(&cctx, 0, mctx); + result = dns_compress_init(&zcctx, 0, mctx); check_result(result, "dns_compress_init"); result = isc_buffer_allocate(mctx, &wirebuf, MXNAME); check_result(result, "isc_buffer_allocate"); - result = dns_name_towire(&(fname.name), &cctx, + result = dns_name_towire(&(fname.name), &zcctx, wirebuf); check_result(result, "dns_name_towire"); optattr[optlist.used].value.base = @@ -1487,7 +1492,7 @@ setup_lookup(dig_lookup_t *lookup) { optattr[optlist.used].value.length = isc_buffer_usedlength(wirebuf); optlist.used++; - dns_compress_invalidate(&cctx); + dns_compress_invalidate(&zcctx); } if (lookup->viewname[0] != 0) { optattr[optlist.used].code = DNS_OPTCODE_VIEW; @@ -1516,6 +1521,8 @@ setup_lookup(dig_lookup_t *lookup) { check_result(result, "dns_message_renderend"); debug("done rendering"); + dns_compress_invalidate(&cctx); + /* * Force TCP mode if the request is larger than 512 bytes. */ @@ -2678,7 +2685,7 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { fatal("Couldn't find server '%s': %s", host, gai_strerror(result)); } - memcpy(&sockaddr->type.sa,res->ai_addr, res->ai_addrlen); + memcpy(&sockaddr->type.sa, res->ai_addr, res->ai_addrlen); sockaddr->length = res->ai_addrlen; isc_sockaddr_setport(sockaddr, port); freeaddrinfo(res); diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in index 2fc3b8ffab..39671f7633 100644 --- a/bin/named/Makefile.in +++ b/bin/named/Makefile.in @@ -13,7 +13,7 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.68 2001/03/04 21:21:19 bwelling Exp $ +# $Id: Makefile.in,v 1.69 2001/03/05 21:15:34 bwelling Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -26,10 +26,10 @@ top_srcdir = @top_srcdir@ # # Add database drivers here. # -DBDRIVER_OBJS = -DBDRIVER_SRCS = +DBDRIVER_OBJS = pgsqldb.o +DBDRIVER_SRCS = pgsqldb.c DBDRIVER_INCLUDES = -DBDRIVER_LIBS = +DBDRIVER_LIBS = -lpq CINCLUDES = -I${srcdir}/include -I${srcdir}/unix/include \ ${LWRES_INCLUDES} ${OMAPI_INCLUDES} ${DNS_INCLUDES} \ diff --git a/bin/named/client.c b/bin/named/client.c index 4725903355..e285262aa8 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.154 2001/02/23 22:38:28 bwelling Exp $ */ +/* $Id: client.c,v 1.155 2001/03/05 21:15:35 bwelling Exp $ */ #include @@ -803,6 +803,8 @@ ns_client_send(ns_client_t *client) { isc_buffer_t buffer; isc_buffer_t tcpbuffer; isc_region_t r; + dns_compress_t cctx; + isc_boolean_t cleanup_cctx = ISC_FALSE; REQUIRE(NS_CLIENT_VALID(client)); @@ -818,7 +820,12 @@ ns_client_send(ns_client_t *client) { if (result != ISC_R_SUCCESS) goto done; - result = dns_message_renderbegin(client->message, &buffer); + result = dns_compress_init(&cctx, -1, client->mctx); + if (result != ISC_R_SUCCESS) + goto done; + cleanup_cctx = ISC_TRUE; + + result = dns_message_renderbegin(client->message, &cctx, &buffer); if (result != ISC_R_SUCCESS) goto done; if (client->opt != NULL) { @@ -864,6 +871,11 @@ ns_client_send(ns_client_t *client) { if (result != ISC_R_SUCCESS) goto done; + if (cleanup_cctx) { + dns_compress_invalidate(&cctx); + cleanup_cctx = ISC_FALSE; + } + if (TCP_CLIENT(client)) { isc_buffer_usedregion(&buffer, &r); isc_buffer_putuint16(&tcpbuffer, (isc_uint16_t) r.length); @@ -879,6 +891,10 @@ ns_client_send(ns_client_t *client) { isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE); client->tcpbuf = NULL; } + + if (cleanup_cctx) + dns_compress_invalidate(&cctx); + ns_client_next(client, result); } diff --git a/bin/named/main.c b/bin/named/main.c index 3bb5e5260f..e69c7120b6 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: main.c,v 1.103 2001/01/11 23:46:10 bwelling Exp $ */ +/* $Id: main.c,v 1.104 2001/03/05 21:15:36 bwelling Exp $ */ #include @@ -56,6 +56,7 @@ * Include header files for database drivers here. */ /* #include "xxdb.h" */ +#include "pgsqldb.h" static isc_boolean_t want_stats = ISC_FALSE; static const char * program_name = "named"; @@ -496,6 +497,7 @@ setup(void) { * Add calls to register sdb drivers here. */ /* xxdb_init(); */ + pgsqldb_init(); ns_server_create(ns_g_mctx, &ns_g_server); @@ -517,6 +519,7 @@ cleanup(void) { * Add calls to unregister sdb drivers here. */ /* xxdb_clear(); */ + pgsqldb_clear(); isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, ISC_LOG_NOTICE, "exiting"); diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index 43ac5e15bd..bb7322bd9f 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrout.c,v 1.95 2001/02/26 03:52:30 marka Exp $ */ +/* $Id: xfrout.c,v 1.96 2001/03/05 21:15:37 bwelling Exp $ */ #include @@ -1263,6 +1263,8 @@ sendstream(xfrout_ctx_t *xfr) { dns_rdata_t *msgrdata = NULL; dns_rdatalist_t *msgrdl = NULL; dns_rdataset_t *msgrds = NULL; + dns_compress_t cctx; + isc_boolean_t cleanup_cctx = ISC_FALSE; int n_rrs; @@ -1448,10 +1450,14 @@ sendstream(xfrout_ctx_t *xfr) { } if ((xfr->client->attributes & NS_CLIENTATTR_TCP) != 0) { - CHECK(dns_message_renderbegin(msg, &xfr->txbuf)); + CHECK(dns_compress_init(&cctx, -1, xfr->mctx)); + cleanup_cctx = ISC_TRUE; + CHECK(dns_message_renderbegin(msg, &cctx, &xfr->txbuf)); CHECK(dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0)); CHECK(dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0)); CHECK(dns_message_renderend(msg)); + dns_compress_invalidate(&cctx); + cleanup_cctx = ISC_FALSE; isc_buffer_usedregion(&xfr->txbuf, &used); isc_buffer_putuint16(&xfr->txlenbuf, used.length); @@ -1497,6 +1503,8 @@ sendstream(xfrout_ctx_t *xfr) { if (tcpmsg != NULL) dns_message_destroy(&tcpmsg); + if (cleanup_cctx) + dns_compress_invalidate(&cctx); /* * Make sure to release any locks held by database * iterators before returning from the event handler. diff --git a/bin/tests/sig0_test.c b/bin/tests/sig0_test.c index 12b396d973..b11d93e88f 100644 --- a/bin/tests/sig0_test.c +++ b/bin/tests/sig0_test.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sig0_test.c,v 1.5 2001/01/09 21:41:39 bwelling Exp $ */ +/* $Id: sig0_test.c,v 1.6 2001/03/05 21:15:38 bwelling Exp $ */ #include @@ -136,6 +136,7 @@ buildquery(void) { isc_buffer_t namesrc, namedst; unsigned char namedata[256]; isc_sockaddr_t sa; + dns_compress_t cctx; query = NULL; result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query); @@ -162,6 +163,8 @@ buildquery(void) { isc_buffer_init(&qbuffer, qdata, sizeof(qdata)); + result = dns_compress_init(&cctx, -1, mctx); + CHECK("dns_compress_init", result); result = dns_message_renderbegin(query, &qbuffer); CHECK("dns_message_renderbegin", result); result = dns_message_rendersection(query, DNS_SECTION_QUESTION, 0); @@ -174,6 +177,7 @@ buildquery(void) { CHECK("dns_message_rendersection(add)", result); result = dns_message_renderend(query); CHECK("dns_message_renderend", result); + dns_compress_invalidate(&cctx); isc_buffer_init(&outbuf, output, sizeof(output)); result = dns_message_totext(query, 0, &outbuf); diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index 651688a274..6ef67e6126 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: wire_test.c,v 1.54 2001/01/09 21:41:48 bwelling Exp $ */ +/* $Id: wire_test.c,v 1.55 2001/03/05 21:15:40 bwelling Exp $ */ #include @@ -62,10 +62,11 @@ main(int argc, char *argv[]) { int n; FILE *f; isc_boolean_t need_close = ISC_FALSE; - unsigned char b[1000]; - char s[1000]; + unsigned char b[4000]; + char s[4000]; dns_message_t *message; isc_result_t result; + dns_compress_t cctx; isc_mem_t *mctx; mctx = NULL; @@ -126,7 +127,7 @@ main(int argc, char *argv[]) { CHECKRESULT(result, "dns_message_create failed"); result = dns_message_parse(message, &source, 0); - CHECKRESULT(result, "dns_message_parse failed"); +/* CHECKRESULT(result, "dns_message_parse failed");*/ result = printmessage(message); CHECKRESULT(result, "printmessage() failed"); @@ -145,6 +146,9 @@ main(int argc, char *argv[]) { for (i = 0 ; i < DNS_SECTION_MAX ; i++) message->counts[i] = 0; /* Another hack XXX */ + result = dns_compress_init(&cctx, -1, mctx); + CHECKRESULT(result, "dns_compress_init() failed"); + result = dns_message_renderbegin(message, &source); CHECKRESULT(result, "dns_message_renderbegin() failed"); @@ -162,6 +166,8 @@ main(int argc, char *argv[]) { dns_message_renderend(message); + dns_compress_invalidate(&cctx); + message->from_to_wire = DNS_MESSAGE_INTENTPARSE; dns_message_destroy(&message); diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 1a97123919..f9ed39fc46 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.h,v 1.94 2001/02/23 01:52:18 bwelling Exp $ */ +/* $Id: message.h,v 1.95 2001/03/05 21:15:47 bwelling Exp $ */ #ifndef DNS_MESSAGE_H #define DNS_MESSAGE_H 1 @@ -182,7 +182,6 @@ struct dns_message { int state; unsigned int from_to_wire : 2; - unsigned int need_cctx_cleanup : 1; unsigned int header_ok : 1; unsigned int question_ok : 1; unsigned int tcp_continuation : 1; @@ -196,7 +195,7 @@ struct dns_message { unsigned int reserved; /* reserved space (render) */ isc_buffer_t *buffer; - dns_compress_t cctx; + dns_compress_t *cctx; isc_mem_t *mctx; isc_mempool_t *namepool; @@ -417,11 +416,15 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, */ isc_result_t -dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer); +dns_message_renderbegin(dns_message_t *msg, dns_compress_t *cctx, + isc_buffer_t *buffer); /* * Begin rendering on a message. Only one call can be made to this function * per message. * + * The compression context is "owned" by the message library until + * dns_message_renderend() is called. It must be invalidated by the caller. + * * The buffer is "owned" by the message library until dns_message_renderend() * is called. * @@ -429,6 +432,8 @@ dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer); * * 'msg' be valid. * + * 'cctx' be valid. + * * 'buffer' is a valid buffer. * * Side Effects: @@ -438,7 +443,6 @@ dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer); * Returns: * ISC_R_SUCCESS -- all is well * ISC_R_NOSPACE -- output buffer is too small - * Anything that dns_compress_init() can return. */ isc_result_t diff --git a/lib/dns/message.c b/lib/dns/message.c index 2ee777168c..2351536a04 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.184 2001/03/05 20:12:49 bwelling Exp $ */ +/* $Id: message.c,v 1.185 2001/03/05 21:15:41 bwelling Exp $ */ /*** *** Imports @@ -366,7 +366,6 @@ msginitprivate(dns_message_t *m) { m->sig_reserved = 0; m->reserved = 0; m->buffer = NULL; - m->need_cctx_cleanup = 0; } static inline void @@ -586,9 +585,6 @@ msgreset(dns_message_t *msg, isc_boolean_t everything) { msgblock = next_msgblock; } - if (msg->need_cctx_cleanup == 1) - dns_compress_invalidate(&msg->cctx); - if (msg->tsigkey != NULL) { dns_tsigkey_detach(&msg->tsigkey); msg->tsigkey = NULL; @@ -734,6 +730,8 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) goto cleanup; ISC_LIST_APPEND(m->scratchpad, dynbuf, link); + m->cctx = NULL; + *msgp = m; return (ISC_R_SUCCESS); @@ -1591,15 +1589,18 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, } isc_result_t -dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer) { +dns_message_renderbegin(dns_message_t *msg, dns_compress_t *cctx, + isc_buffer_t *buffer) +{ isc_region_t r; - isc_result_t result; REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(buffer != NULL); REQUIRE(msg->buffer == NULL); REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER); + msg->cctx = cctx; + /* * Erase the contents of this buffer. */ @@ -1615,11 +1616,6 @@ dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer) { if (r.length < msg->reserved) return (ISC_R_NOSPACE); - result = dns_compress_init(&msg->cctx, -1, msg->mctx); - if (result != ISC_R_SUCCESS) - return (result); - msg->need_cctx_cleanup = 1; - /* * Reserve enough space for the header in this buffer. */ @@ -1775,7 +1771,7 @@ dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid, count = 0; result = dns_rdataset_towiresorted(rdataset, name, - &msg->cctx, + msg->cctx, msg->buffer, msg->order, msg->order_arg, @@ -1798,7 +1794,7 @@ dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid, */ if (result != ISC_R_SUCCESS) { INSIST(st.used < 65536); - dns_compress_rollback(&msg->cctx, + dns_compress_rollback(msg->cctx, (isc_uint16_t)st.used); *(msg->buffer) = st; /* rollback */ msg->buffer->length += msg->reserved; @@ -1900,7 +1896,7 @@ dns_message_renderend(dns_message_t *msg) { */ count = 0; result = dns_rdataset_towire(msg->opt, dns_rootname, - &msg->cctx, msg->buffer, &count); + msg->cctx, msg->buffer, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); @@ -1923,7 +1919,7 @@ dns_message_renderend(dns_message_t *msg) { msg->buffer = buf; isc_buffer_clear(msg->buffer); isc_buffer_add(msg->buffer, DNS_MESSAGE_HEADERLEN); - dns_compress_rollback(&msg->cctx, 0); + dns_compress_rollback(msg->cctx, 0); result = dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0); if (result != ISC_R_SUCCESS && result != ISC_R_NOSPACE) @@ -1941,7 +1937,7 @@ dns_message_renderend(dns_message_t *msg) { return (result); count = 0; result = dns_rdataset_towire(msg->tsig, msg->tsigname, - &msg->cctx, msg->buffer, &count); + msg->cctx, msg->buffer, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); @@ -1963,7 +1959,7 @@ dns_message_renderend(dns_message_t *msg) { * be set in a message being rendered. */ result = dns_rdataset_towire(msg->sig0, dns_rootname, - &msg->cctx, msg->buffer, &count); + msg->cctx, msg->buffer, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); @@ -1976,9 +1972,6 @@ dns_message_renderend(dns_message_t *msg) { msg->buffer = NULL; /* forget about this buffer only on success XXX */ - dns_compress_invalidate(&msg->cctx); - msg->need_cctx_cleanup = 0; - return (ISC_R_SUCCESS); } diff --git a/lib/dns/request.c b/lib/dns/request.c index 2ccb95c6d9..25804e86f6 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: request.c,v 1.57 2001/02/13 21:06:25 gson Exp $ */ +/* $Id: request.c,v 1.58 2001/03/05 21:15:42 bwelling Exp $ */ #include @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -935,6 +936,8 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp, isc_result_t result; isc_region_t r; isc_boolean_t tcp = ISC_FALSE; + dns_compress_t cctx; + isc_boolean_t cleanup_cctx = ISC_FALSE; REQUIRE(bufferp != NULL && *bufferp == NULL); @@ -947,10 +950,15 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp, if (result != ISC_R_SUCCESS) return (result); + result = dns_compress_init(&cctx, -1, mctx); + if (result != ISC_R_SUCCESS) + return (result); + cleanup_cctx = ISC_TRUE; + /* * Render message. */ - result = dns_message_renderbegin(message, buf1); + result = dns_message_renderbegin(message, &cctx, buf1); if (result != ISC_R_SUCCESS) goto cleanup; result = dns_message_rendersection(message, DNS_SECTION_QUESTION, 0); @@ -969,6 +977,9 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp, if (result != ISC_R_SUCCESS) goto cleanup; + dns_compress_invalidate(&cctx); + cleanup_cctx = ISC_FALSE; + /* * Copy rendered message to exact sized buffer. */ @@ -1001,6 +1012,8 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp, isc_buffer_free(&buf1); if (buf2 != NULL) isc_buffer_free(&buf2); + if (cleanup_cctx) + dns_compress_invalidate(&cctx); return (result); } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 44a9bf0d97..dff1e84e62 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.206 2001/02/28 21:19:53 bwelling Exp $ */ +/* $Id: resolver.c,v 1.207 2001/03/05 21:15:44 bwelling Exp $ */ #include @@ -854,6 +854,8 @@ resquery_send(resquery_t *query) { dns_peer_t *peer = NULL; isc_boolean_t bogus; isc_boolean_t aborted = ISC_FALSE; + dns_compress_t cctx; + isc_boolean_t cleanup_cctx = ISC_FALSE; fctx = query->fctx; QTRACE("send"); @@ -926,7 +928,13 @@ resquery_send(resquery_t *query) { /* * Convert the question to wire format. */ - result = dns_message_renderbegin(fctx->qmessage, &query->buffer); + result = dns_compress_init(&cctx, -1, fctx->res->mctx); + if (result != ISC_R_SUCCESS) + goto cleanup_message; + cleanup_cctx = ISC_TRUE; + + result = dns_message_renderbegin(fctx->qmessage, &cctx, + &query->buffer); if (result != ISC_R_SUCCESS) goto cleanup_message; @@ -1004,6 +1012,9 @@ resquery_send(resquery_t *query) { if (result != ISC_R_SUCCESS) goto cleanup_message; + dns_compress_invalidate(&cctx); + cleanup_cctx = ISC_FALSE; + if (dns_message_gettsigkey(fctx->qmessage) != NULL) { dns_tsigkey_attach(dns_message_gettsigkey(fctx->qmessage), &query->tsigkey); @@ -1083,6 +1094,9 @@ resquery_send(resquery_t *query) { return (ISC_R_SUCCESS); cleanup_message: + if (cleanup_cctx) + dns_compress_invalidate(&cctx); + dns_message_reset(fctx->qmessage, DNS_MESSAGE_INTENTRENDER); /* diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 3ac7f4cad2..c06cacfd53 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrin.c,v 1.114 2001/02/09 06:04:51 marka Exp $ */ +/* $Id: xfrin.c,v 1.115 2001/03/05 21:15:45 bwelling Exp $ */ #include @@ -219,7 +219,7 @@ static void maybe_free(dns_xfrin_ctx_t *xfr); static void xfrin_fail(dns_xfrin_ctx_t *xfr, isc_result_t result, const char *msg); static isc_result_t -render(dns_message_t *msg, isc_buffer_t *buf); +render(dns_message_t *msg, isc_mem_t *mctx, isc_buffer_t *buf); static void xfrin_logv(int level, dns_name_t *zonename, dns_rdataclass_t rdclass, @@ -795,10 +795,14 @@ xfrin_start(dns_xfrin_ctx_t *xfr) { /* XXX the resolver could use this, too */ static isc_result_t -render(dns_message_t *msg, isc_buffer_t *buf) { +render(dns_message_t *msg, isc_mem_t *mctx, isc_buffer_t *buf) { + dns_compress_t cctx; + isc_boolean_t cleanup_cctx = ISC_FALSE; isc_result_t result; - CHECK(dns_message_renderbegin(msg, buf)); + CHECK(dns_compress_init(&cctx, -1, mctx)); + cleanup_cctx = ISC_TRUE; + CHECK(dns_message_renderbegin(msg, &cctx, buf)); CHECK(dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0)); CHECK(dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0)); CHECK(dns_message_rendersection(msg, DNS_SECTION_AUTHORITY, 0)); @@ -806,6 +810,8 @@ render(dns_message_t *msg, isc_buffer_t *buf) { CHECK(dns_message_renderend(msg)); result = ISC_R_SUCCESS; failure: + if (cleanup_cctx) + dns_compress_invalidate(&cctx); return (result); } @@ -952,7 +958,7 @@ xfrin_send_request(dns_xfrin_ctx_t *xfr) { xfr->id++; msg->id = xfr->id; - CHECK(render(msg, &xfr->qbuffer)); + CHECK(render(msg, xfr->mctx, &xfr->qbuffer)); /* * Free the last tsig, if there is one.