aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-31 17:19:29 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-31 17:19:29 +0000
commit60383ec549918fe5f0a1bbdda09fd74abac56e09 (patch)
treee21d2da77f9c8f836e641fd3e3fca8077ae2334e
parenta7d2ffaef760aa8d61b34a2426e7215e781ff7d4 (diff)
downloadrspamd-60383ec549918fe5f0a1bbdda09fd74abac56e09.tar.gz
rspamd-60383ec549918fe5f0a1bbdda09fd74abac56e09.zip
[Project] Enable language detector init in scanner workers
-rw-r--r--src/rspamd_proxy.c6
-rw-r--r--src/worker.c12
-rw-r--r--src/worker_private.h8
3 files changed, 18 insertions, 8 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 75002fef8..cf6112b75 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -34,6 +34,7 @@
#include "ottery.h"
#include "unix-std.h"
#include "libserver/milter.h"
+#include "libmime/lang_detection.h"
#include "contrib/zstd/zstd.h"
#ifdef HAVE_NETINET_TCP_H
@@ -145,6 +146,8 @@ struct rspamd_proxy_ctx {
gchar *spam_header;
/* Sessions cache */
void *sessions_cache;
+ /* Language detector */
+ struct rspamd_lang_detector *lang_det;
};
enum rspamd_backend_flags {
@@ -2139,7 +2142,8 @@ start_rspamd_proxy (struct rspamd_worker *worker) {
if (ctx->has_self_scan) {
/* Additional initialisation needed */
- rspamd_worker_init_scanner (worker, ctx->ev_base, ctx->resolver);
+ rspamd_worker_init_scanner (worker, ctx->ev_base, ctx->resolver,
+ &ctx->lang_det);
}
if (worker->srv->cfg->enable_sessions_cache) {
diff --git a/src/worker.c b/src/worker.c
index e001ec288..9dc5fec0f 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -17,8 +17,6 @@
* Rspamd worker implementation
*/
-#include <libserver/rspamd_control.h>
-#include <src/libserver/rspamd_control.h>
#include "config.h"
#include "libutil/util.h"
#include "libutil/map.h"
@@ -36,7 +34,7 @@
#include "worker_private.h"
#include "utlist.h"
#include "libutil/http_private.h"
-#include "monitored.h"
+#include "libmime/lang_detection.h"
#include "unix-std.h"
#include "lua/lua_common.h"
@@ -641,7 +639,8 @@ rspamd_worker_on_terminate (struct rspamd_worker *worker)
void
rspamd_worker_init_scanner (struct rspamd_worker *worker,
struct event_base *ev_base,
- struct rspamd_dns_resolver *resolver)
+ struct rspamd_dns_resolver *resolver,
+ struct rspamd_lang_detector **plang_det)
{
rspamd_stat_init (worker->srv->cfg, ev_base);
g_ptr_array_add (worker->finish_actions,
@@ -660,6 +659,8 @@ rspamd_worker_init_scanner (struct rspamd_worker *worker,
RSPAMD_CONTROL_MONITORED_CHANGE,
rspamd_worker_monitored_handler,
worker->srv->cfg);
+
+ *plang_det = rspamd_language_detector_init (worker->srv->cfg);
}
/*
@@ -685,7 +686,8 @@ start_worker (struct rspamd_worker *worker)
/* XXX: stupid default */
ctx->keys_cache = rspamd_keypair_cache_new (256);
- rspamd_worker_init_scanner (worker, ctx->ev_base, ctx->resolver);
+ rspamd_worker_init_scanner (worker, ctx->ev_base, ctx->resolver,
+ &ctx->lang_det);
rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base,
worker);
diff --git a/src/worker_private.h b/src/worker_private.h
index 50a53a624..fe4a6c4b3 100644
--- a/src/worker_private.h
+++ b/src/worker_private.h
@@ -25,6 +25,8 @@
static const guint64 rspamd_worker_magic = 0xb48abc69d601dc1dULL;
+struct rspamd_lang_detector;
+
struct rspamd_worker_ctx {
guint64 magic;
/* Events base */
@@ -52,14 +54,16 @@ struct rspamd_worker_ctx {
struct rspamd_cryptobox_keypair *key;
/* Keys cache */
struct rspamd_keypair_cache *keys_cache;
+ /* Language detector */
+ struct rspamd_lang_detector *lang_det;
};
-
/*
* Init scanning routines
*/
void rspamd_worker_init_scanner (struct rspamd_worker *worker,
struct event_base *ev_base,
- struct rspamd_dns_resolver *resolver);
+ struct rspamd_dns_resolver *resolver,
+ struct rspamd_lang_detector **plang_det);
/*
* Called on forced timeout