diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
commit | fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b (patch) | |
tree | c84e6a5d4c5cd78a7a2cc3c7adbc7af5d0541682 /src/libserver/dns.c | |
parent | e0483657ff6cf1adc828ccce457814d61fe90a0d (diff) | |
download | rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip |
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/libserver/dns.c')
-rw-r--r-- | src/libserver/dns.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c index a95232fca..c1303e3ea 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -26,9 +26,9 @@ #include "config.h" #include "dns.h" #include "main.h" -#include "rdns_event.h" -#include "uthash.h" #include "utlist.h" +#include "uthash.h" +#include "rdns_event.h" struct rspamd_dns_resolver { struct rdns_resolver *r; @@ -48,7 +48,7 @@ static void rspamd_dns_fin_cb (gpointer arg) { struct rdns_request *req = arg; - + rdns_request_release (req); } @@ -67,33 +67,25 @@ rspamd_dns_callback (struct rdns_reply *reply, gpointer ud) remove_normal_event (reqdata->session, rspamd_dns_fin_cb, reqdata->req); } -gboolean +gboolean make_dns_request (struct rspamd_dns_resolver *resolver, - struct rspamd_async_session *session, - rspamd_mempool_t *pool, - dns_callback_type cb, - gpointer ud, - enum rdns_request_type type, - const char *name) + struct rspamd_async_session *session, rspamd_mempool_t *pool, dns_callback_type cb, + gpointer ud, enum rdns_request_type type, const char *name) { struct rdns_request *req; struct rspamd_dns_request_ud *reqdata; - - reqdata = - rspamd_mempool_alloc (pool, sizeof (struct rspamd_dns_request_ud)); + + reqdata = rspamd_mempool_alloc (pool, sizeof (struct rspamd_dns_request_ud)); reqdata->session = session; reqdata->cb = cb; reqdata->ud = ud; req = rdns_make_request_full (resolver->r, rspamd_dns_callback, reqdata, - resolver->request_timeout, resolver->max_retransmits, 1, name, - type); + resolver->request_timeout, resolver->max_retransmits, 1, name, type); if (req != NULL) { - register_async_event (session, - (event_finalizer_t)rspamd_dns_fin_cb, - req, - g_quark_from_static_string ("dns resolver")); + register_async_event (session, (event_finalizer_t)rspamd_dns_fin_cb, req, + g_quark_from_static_string ("dns resolver")); reqdata->req = req; } else { @@ -105,15 +97,13 @@ make_dns_request (struct rspamd_dns_resolver *resolver, struct rspamd_dns_resolver * -dns_resolver_init (rspamd_logger_t *logger, - struct event_base *ev_base, - struct rspamd_config *cfg) +dns_resolver_init (rspamd_logger_t *logger, struct event_base *ev_base, struct rspamd_config *cfg) { - GList *cur; - struct rspamd_dns_resolver *new; - gchar *begin, *p, *err; - gint priority; - + GList *cur; + struct rspamd_dns_resolver *new; + gchar *begin, *p, *err; + gint priority; + new = g_slice_alloc0 (sizeof (struct rspamd_dns_resolver)); new->ev_base = ev_base; new->request_timeout = cfg->dns_timeout; @@ -122,15 +112,12 @@ dns_resolver_init (rspamd_logger_t *logger, new->r = rdns_resolver_new (); rdns_bind_libevent (new->r, new->ev_base); rdns_resolver_set_log_level (new->r, cfg->log_level); - rdns_resolver_set_logger (new->r, - (rdns_log_function)rspamd_common_logv, - logger); + rdns_resolver_set_logger (new->r, (rdns_log_function)rspamd_common_logv, logger); if (cfg->nameservers == NULL) { /* Parse resolv.conf */ if (!rdns_resolver_parse_resolv_conf (new->r, "/etc/resolv.conf")) { - msg_err ( - "cannot parse resolv.conf and no nameservers defined, so no ways to resolve addresses"); + msg_err ("cannot parse resolv.conf and no nameservers defined, so no ways to resolve addresses"); return new; } } @@ -141,19 +128,16 @@ dns_resolver_init (rspamd_logger_t *logger, p = strchr (begin, ':'); if (p != NULL) { *p = '\0'; - p++; + p ++; priority = strtoul (p, &err, 10); if (err != NULL && *err != '\0') { - msg_info ( - "bad character '%x', must be 'm' or 's' or a numeric priority", - *err); + msg_info ("bad character '%x', must be 'm' or 's' or a numeric priority", *err); } } else { priority = 0; } - if (!rdns_resolver_add_server (new->r, begin, 53, priority, - cfg->dns_io_per_server)) { + if (!rdns_resolver_add_server (new->r, begin, 53, priority, cfg->dns_io_per_server)) { msg_warn ("cannot parse ip address of nameserver: %s", begin); cur = g_list_next (cur); continue; |