commit c408720: [Minor] Allow to deinit resolver
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Sep 27 12:35:07 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-09-27 12:46:54 +0100
URL: https://github.com/rspamd/rspamd/commit/c408720e08599ffecadaf1db2506d0afb5e72692
[Minor] Allow to deinit resolver
---
src/libserver/dns.c | 16 ++++++++++++++++
src/libserver/dns.h | 5 ++++-
2 files changed, 20 insertions(+), 1 deletion(-)
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;
More information about the Commits
mailing list