From: Vsevolod Stakhov Date: Fri, 27 Sep 2019 11:46:54 +0000 (+0100) Subject: [Minor] Allow to deinit resolver X-Git-Tag: 2.0~112 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c408720e08599ffecadaf1db2506d0afb5e72692;p=rspamd.git [Minor] Allow to deinit resolver --- diff --git a/src/libserver/dns.c b/src/libserver/dns.c index cf4279cf0..bbc9c2b45 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -642,6 +642,22 @@ rspamd_dns_resolver_init (rspamd_logger_t *logger, return dns_resolver; } +void +rspamd_dns_resolver_deinit (struct rspamd_dns_resolver *resolver) +{ + if (resolver) { + if (resolver->r) { + rdns_resolver_release (resolver->r); + } + + if (resolver->ups) { + rspamd_upstreams_destroy (resolver->ups); + } + + g_free (resolver); + } +} + static struct rdns_upstream_elt* rspamd_dns_select_upstream (const char *name, diff --git a/src/libserver/dns.h b/src/libserver/dns.h index a9d822703..87cc0954b 100644 --- a/src/libserver/dns.h +++ b/src/libserver/dns.h @@ -46,7 +46,10 @@ struct rspamd_dns_resolver { * Init DNS resolver, params are obtained from a config file or system file /etc/resolv.conf */ struct rspamd_dns_resolver *rspamd_dns_resolver_init (rspamd_logger_t *logger, - struct ev_loop *ev_base, struct rspamd_config *cfg); + struct ev_loop *ev_base, + struct rspamd_config *cfg); + +void rspamd_dns_resolver_deinit (struct rspamd_dns_resolver *resolver); struct rspamd_dns_request_ud;