From 505e9556c01fe56a73e5582d33cc492c4a1815d1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 29 Oct 2014 15:02:51 +0000 Subject: [PATCH] Fix build. --- src/controller.c | 1 + src/libserver/dns.c | 7 ------- src/libserver/dns.h | 7 ++++++- src/libutil/CMakeLists.txt | 1 + src/libutil/upstream.c | 26 +++++++++++++++----------- src/smtp_proxy.c | 1 + src/worker.c | 2 ++ 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/controller.c b/src/controller.c index 02a5d4d2e..dafbe5bc1 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1734,6 +1734,7 @@ start_controller_worker (struct rspamd_worker *worker) ctx->ev_base, worker->srv->cfg); + rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); /* Maps events */ start_map_watch (worker->srv->cfg, ctx->ev_base); diff --git a/src/libserver/dns.c b/src/libserver/dns.c index 1410442b7..3e97160af 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -30,13 +30,6 @@ #include "uthash.h" #include "rdns_event.h" -struct rspamd_dns_resolver { - struct rdns_resolver *r; - struct event_base *ev_base; - gdouble request_timeout; - guint max_retransmits; -}; - struct rspamd_dns_request_ud { struct rspamd_async_session *session; dns_callback_type cb; diff --git a/src/libserver/dns.h b/src/libserver/dns.h index 4882f539d..ffe80fae0 100644 --- a/src/libserver/dns.h +++ b/src/libserver/dns.h @@ -32,7 +32,12 @@ #include "logger.h" #include "rdns.h" -struct rspamd_dns_resolver; +struct rspamd_dns_resolver { + struct rdns_resolver *r; + struct event_base *ev_base; + gdouble request_timeout; + guint max_retransmits; +}; /* Rspamd DNS API */ diff --git a/src/libutil/CMakeLists.txt b/src/libutil/CMakeLists.txt index 01c88769b..d7894ea7c 100644 --- a/src/libutil/CMakeLists.txt +++ b/src/libutil/CMakeLists.txt @@ -30,6 +30,7 @@ TARGET_LINK_LIBRARIES(rspamd-util ottery) TARGET_LINK_LIBRARIES(rspamd-util rspamd-http-parser) TARGET_LINK_LIBRARIES(rspamd-util event) TARGET_LINK_LIBRARIES(rspamd-util xxhash) +TARGET_LINK_LIBRARIES(rspamd-util rdns) IF(OPENSSL_FOUND) TARGET_LINK_LIBRARIES(rspamd-util ${OPENSSL_LIBRARIES}) ENDIF(OPENSSL_FOUND) diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index fb469242f..595b6cd0b 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -191,21 +191,25 @@ rspamd_upstream_set_inactive (struct upstream_list *ls, struct upstream *up) g_ptr_array_remove_index (ls->alive, up->active_idx); up->active_idx = -1; - /* Resolve name of the upstream one more time */ - if (up->name[0] != '/') { - REF_RETAIN (up); - rdns_make_request_full (res, rspamd_upstream_dns_cb, up, - default_dns_timeout, default_dns_retransmits, - RDNS_REQUEST_A, up->name); - REF_RETAIN (up); - rdns_make_request_full (res, rspamd_upstream_dns_cb, up, - default_dns_timeout, default_dns_retransmits, - RDNS_REQUEST_AAAA, up->name); + if (res != NULL) { + /* Resolve name of the upstream one more time */ + if (up->name[0] != '/') { + REF_RETAIN (up); + rdns_make_request_full (res, rspamd_upstream_dns_cb, up, + default_dns_timeout, default_dns_retransmits, + RDNS_REQUEST_A, up->name); + REF_RETAIN (up); + rdns_make_request_full (res, rspamd_upstream_dns_cb, up, + default_dns_timeout, default_dns_retransmits, + RDNS_REQUEST_AAAA, up->name); + } } REF_RETAIN (up); evtimer_set (&up->ev, rspamd_upstream_revive_cb, up); - event_base_set (ev_base, &up->ev); + if (ev_base != NULL) { + event_base_set (ev_base, &up->ev); + } up->tv.tv_sec = default_revive_time; up->tv.tv_usec = 0; event_add (&up->ev, &up->tv); diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c index 9b31c9498..7e881994f 100644 --- a/src/smtp_proxy.c +++ b/src/smtp_proxy.c @@ -1072,6 +1072,7 @@ start_smtp_proxy (struct rspamd_worker *worker) ctx->ev_base, worker->srv->cfg); + rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); /* Set umask */ umask (S_IWGRP | S_IWOTH | S_IROTH | S_IRGRP); diff --git a/src/worker.c b/src/worker.c index c562528a3..afd9a9b72 100644 --- a/src/worker.c +++ b/src/worker.c @@ -318,6 +318,8 @@ start_worker (struct rspamd_worker *worker) ctx->ev_base, worker->srv->cfg); + rspamd_upstreams_library_init (ctx->resolver->r, ctx->ev_base); + /* Create classify pool */ ctx->classify_pool = NULL; if (ctx->classify_threads > 1) { -- 2.39.5