#include "fuzzy_wire.h"
#include "unix-std.h"
#include "utlist.h"
+#include "libmime/lang_detection.h"
#include <math.h>
/* 60 seconds for worker's IO */
struct event *rrd_event;
struct rspamd_rrd_file *rrd;
struct event save_stats_event;
+ struct rspamd_lang_detector *lang_det;
};
struct rspamd_controller_plugin_cbdata {
if (lua_isfunction (L, -1)) {
task = rspamd_task_new (session->ctx->worker, session->cfg,
- session->pool);
+ session->pool, ctx->lang_det);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
return 0;
}
- task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool);
+ task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool,
+ ctx->lang_det);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
return 0;
}
- task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool);
+ task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool,
+ session->ctx->lang_det);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
return 0;
}
- task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool);
+ task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool,
+ ctx->lang_det);
task->ev_base = session->ctx->ev_base;
task->resolver = ctx->resolver;
rspamd_mempool_stat (&mem_st);
memcpy (&stat_copy, session->ctx->worker->srv->stat, sizeof (stat_copy));
stat = &stat_copy;
- task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool);
-
ctx = session->ctx;
+
+ task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool,
+ ctx->lang_det);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
cbdata = rspamd_mempool_alloc0 (session->pool, sizeof (*cbdata));
return 0;
}
- task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool);
+ task = rspamd_task_new (session->ctx->worker, session->cfg, session->pool,
+ ctx->lang_det);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
g_ptr_array_add (worker->finish_actions,
(gpointer)rspamd_controller_on_terminate);
rspamd_controller_load_saved_stats (ctx);
+ ctx->lang_det = ctx->cfg->lang_det;
/* RRD collector */
if (ctx->cfg->rrd_file && worker->index == 0) {
struct rspamd_config_post_load_script *prev, *next;
};
+struct rspamd_lang_detector;
+
/**
* Structure that stores all config data
*/
gchar *zstd_output_dictionary; /**< path to zstd output dictionary */
ucl_object_t *neighbours; /**< other servers in the cluster */
+ struct rspamd_lang_detector *lang_det; /**< language detector */
+
ref_entry_t ref; /**< reference counter */
};
#include "cryptobox.h"
#include "libutil/multipattern.h"
#include "libmime/email_addr.h"
+#include "libmime/lang_detection.h"
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
return FALSE;
}
+ cfg->lang_det = rspamd_language_detector_init (cfg);
+
return TRUE;
}
#include "utlist.h"
#include "contrib/zstd/zstd.h"
#include "libserver/mempool_vars_internal.h"
+#include "libmime/lang_detection.h"
#include <math.h>
/*
*/
struct rspamd_task *
rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
- rspamd_mempool_t *pool)
+ rspamd_mempool_t *pool,
+ struct rspamd_lang_detector *lang_det)
{
struct rspamd_task *new_task;
gettimeofday (&new_task->tv, NULL);
new_task->time_real = rspamd_get_ticks (FALSE);
new_task->time_virtual = rspamd_get_virtual_ticks ();
+ new_task->lang_det = lang_det;
if (pool == NULL) {
new_task->task_pool =
#define RSPAMD_TASK_IS_PROFILING(task) (((task)->flags & RSPAMD_TASK_FLAG_PROFILE))
struct rspamd_email_address;
+struct rspamd_lang_detector;
enum rspamd_newlines_type;
/**
ucl_object_t *settings; /**< Settings applied to task */
const gchar *classifier; /**< Classifier to learn (if needed) */
+ struct rspamd_lang_detector *lang_det; /**< Languages detector */
guchar digest[16];
};
*/
struct rspamd_task *rspamd_task_new (struct rspamd_worker *worker,
struct rspamd_config *cfg,
- rspamd_mempool_t *pool);
+ rspamd_mempool_t *pool,
+ struct rspamd_lang_detector *lang_det);
/**
* Destroy task object and remove its IO dispatcher if it exists
*/
if (cfg != NULL && message != NULL) {
base = event_init ();
rspamd_init_filters (cfg, FALSE);
- task = rspamd_task_new (NULL, cfg, NULL);
+ task = rspamd_task_new (NULL, cfg, NULL, NULL);
task->ev_base = base;
task->msg.begin = rspamd_mempool_alloc (task->task_pool, mlen);
rspamd_strlcpy ((gpointer)task->msg.begin, message, mlen);
gint r, *saved, rules = 0, err_idx;
/* Prepare task */
- task = rspamd_task_new (session->wrk, session->cfg, NULL);
+ task = rspamd_task_new (session->wrk, session->cfg, NULL, NULL);
task->cfg = ctx->cfg;
task->ev_base = conn_ent->rt->ev_base;
saved = rspamd_mempool_alloc0 (session->pool, sizeof (gint));
rspamd_printf ("cannot open %s: %s\n", argv[i], strerror (errno));
}
else {
- task = rspamd_task_new (NULL, NULL, NULL);
+ task = rspamd_task_new (NULL, NULL, NULL, NULL);
if (!rspamd_task_load_message (task, NULL, map, len)) {
rspamd_printf ("cannot load %s\n", argv[i]);
msg = session->client_message;
task = rspamd_task_new (session->worker, session->ctx->cfg,
- session->pool);
+ session->pool, session->ctx->lang_det);
task->flags |= RSPAMD_TASK_FLAG_MIME;
task->sock = -1;
if (cfg->finish_callbacks) {
ctx = worker->ctx;
/* Create a fake task object for async events */
- task = rspamd_task_new (worker, cfg, NULL);
+ task = rspamd_task_new (worker, cfg, NULL, NULL);
task->resolver = ctx->resolver;
task->ev_base = ctx->ev_base;
task->flags |= RSPAMD_TASK_FLAG_PROCESSING;
return;
}
- task = rspamd_task_new (worker, ctx->cfg, NULL);
+ task = rspamd_task_new (worker, ctx->cfg, NULL, ctx->lang_det);
msg_info_task ("accepted connection from %s port %d, task ptr: %p",
rspamd_inet_address_to_string (addr),
rspamd_worker_monitored_handler,
worker->srv->cfg);
- *plang_det = rspamd_language_detector_init (worker->srv->cfg);
+ *plang_det = worker->srv->cfg;
}
/*