]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Enable language detector init in scanner workers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 31 Dec 2017 17:19:29 +0000 (17:19 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 31 Dec 2017 17:19:29 +0000 (17:19 +0000)
src/rspamd_proxy.c
src/worker.c
src/worker_private.h

index 75002fef8ed48d31a084cbf9b3de536df205b8fd..cf6112b7588bb27e90b199a831ddfb6da728c596 100644 (file)
@@ -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) {
index e001ec288ee228e6f0c7d4a18f458e8a81cbde9d..9dc5fec0fb76ee735cdec6363825b7cca08d2359 100644 (file)
@@ -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);
 
index 50a53a624aadcdfd8583e1a66602412af21343b4..fe4a6c4b39863c38f69a6501a36981e8d3716bb1 100644 (file)
@@ -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