From 19d0e55011f75fce39c8bb8c7d733043b8a0babd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 3 Jan 2022 20:55:54 +0000 Subject: [PATCH] [Project] Rdns: Fix TCP stuff cleanup --- contrib/librdns/resolver.c | 1 + contrib/librdns/util.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c index c5cebc572b..a576135db0 100644 --- a/contrib/librdns/resolver.c +++ b/contrib/librdns/resolver.c @@ -817,6 +817,7 @@ rdns_process_tcp_write (int fd, struct rdns_io_channel *ioc) /* Packet has been fully written, remove it */ DL_DELETE(ioc->tcp->output_chain, oc); /* Data in output buffer belongs to request */ + REF_RELEASE(oc->req); free (oc); ioc->tcp->cur_output_chains --; } diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c index d96103bb70..b7cd99a67a 100644 --- a/contrib/librdns/util.c +++ b/contrib/librdns/util.c @@ -665,6 +665,21 @@ rdns_ioc_tcp_reset (struct rdns_io_channel *ioc) } /* Clean all buffers and temporaries */ + if (ioc->tcp->cur_read_buf) { + free (ioc->tcp->cur_read_buf); + ioc->tcp->read_buf_allocated = 0; + ioc->tcp->next_read_size = 0; + ioc->tcp->cur_read = 0; + } + + struct rdns_tcp_output_chain *oc, *tmp; + DL_FOREACH_SAFE(ioc->tcp->output_chain, oc, tmp) { + REF_RELEASE(oc->req); + DL_DELETE (ioc->tcp->output_chain, oc); + free (oc); + } + + ioc->tcp->cur_output_chains = 0; ioc->flags &= ~RDNS_CHANNEL_CONNECTED; } -- 2.47.3