aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns/resolver.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-02 23:53:55 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-02 23:53:55 +0000
commit3aec3589a45dd71191f47da93656b6b5614903de (patch)
treeed846a6325d6754faf2ad6b6ab0d38e2c3a19a35 /contrib/librdns/resolver.c
parentbe5153fa1b8cc23b03e616fc0288b9f1994754d8 (diff)
downloadrspamd-3aec3589a45dd71191f47da93656b6b5614903de.tar.gz
rspamd-3aec3589a45dd71191f47da93656b6b5614903de.zip
[Project] Rdns: Add reaper for inactive TCP connections
Diffstat (limited to 'contrib/librdns/resolver.c')
-rw-r--r--contrib/librdns/resolver.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index 520e85588..3197230ed 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -526,8 +526,21 @@ static void
rdns_process_periodic (void *arg)
{
struct rdns_resolver *resolver = (struct rdns_resolver*)arg;
+ struct rdns_server *serv;
UPSTREAM_RESCAN (resolver->servers, time (NULL));
+
+ UPSTREAM_FOREACH (resolver->servers, serv) {
+ for (int i = 0; i < serv->tcp_io_cnt; i ++) {
+ if (IS_CHANNEL_CONNECTED(serv->tcp_io_channels[i])) {
+ /* Disconnect channels with no requests in flight */
+ if (kh_size(serv->tcp_io_channels[i]->requests) == 0) {
+ rdns_debug ("reset inactive TCP connection to %s", serv->name);
+ rdns_ioc_tcp_reset (serv->tcp_io_channels[i]);
+ }
+ }
+ }
+ }
}
static void