]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Rdns: Fix TCP stuff cleanup
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jan 2022 20:55:54 +0000 (20:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jan 2022 20:55:54 +0000 (20:55 +0000)
contrib/librdns/resolver.c
contrib/librdns/util.c

index c5cebc572bcf5c9a17e2a0460e6627948f463658..a576135db0fdc4753570b3678c36039d306d298f 100644 (file)
@@ -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 --;
                }
index d96103bb7070f693a69007aefecd4af21f692322..b7cd99a67aa3feaceb3cb1560319af56ce0d72bb 100644 (file)
@@ -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;
        }