From: Vsevolod Stakhov Date: Mon, 3 Jan 2022 20:55:54 +0000 (+0000) Subject: [Project] Rdns: Fix TCP stuff cleanup X-Git-Tag: 3.2~129^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19d0e55011f75fce39c8bb8c7d733043b8a0babd;p=thirdparty%2Frspamd.git [Project] Rdns: Fix TCP stuff cleanup --- 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; }