summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-27 12:46:54 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-27 12:46:54 +0100
commitc408720e08599ffecadaf1db2506d0afb5e72692 (patch)
tree5461dc8ff0ed0cfa2e41bf99972710d7055326f5
parent68cf5243462e0e9b743e420ab57a0be11055fc78 (diff)
downloadrspamd-c408720e08599ffecadaf1db2506d0afb5e72692.tar.gz
rspamd-c408720e08599ffecadaf1db2506d0afb5e72692.zip
[Minor] Allow to deinit resolver
-rw-r--r--src/libserver/dns.c16
-rw-r--r--src/libserver/dns.h5
2 files changed, 20 insertions, 1 deletions
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;