aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 15:45:33 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 15:45:33 +0000
commit4d386d0c689ad4607c67dcd634e53aadea940613 (patch)
treef9290e546342db163e361ba284d31630dc874850 /src/libserver
parent66c4eda320e6a7d7e3d55a3868c1197941d9c259 (diff)
downloadrspamd-4d386d0c689ad4607c67dcd634e53aadea940613.tar.gz
rspamd-4d386d0c689ad4607c67dcd634e53aadea940613.zip
[Minor] Allow to detect worker's scanner flag from lua
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/symbols_cache.c4
-rw-r--r--src/libserver/worker_util.c13
-rw-r--r--src/libserver/worker_util.h2
3 files changed, 6 insertions, 13 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index b890578ed..4c15184d4 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1308,7 +1308,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
diff);
}
- if (rspamd_worker_is_normal (task->worker)) {
+ if (rspamd_worker_is_scanner (task->worker)) {
rspamd_set_counter (item->cd, diff);
}
@@ -2026,7 +2026,7 @@ rspamd_symbols_cache_resort_cb (gint fd, short what, gpointer ud)
double_to_tv (tm, &tv);
event_add (&cbdata->resort_ev, &tv);
- if (rspamd_worker_is_normal (cbdata->w)) {
+ if (rspamd_worker_is_scanner (cbdata->w)) {
rspamd_mempool_lock_mutex (cache->mtx);
/* Gather stats from shared execution times */
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 7c92dc359..f6bc78aaa 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -588,6 +588,7 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
wrk->srv = rspamd_main;
wrk->type = cf->type;
wrk->cf = cf;
+ wrk->flags = cf->worker->flags;
REF_RETAIN (cf);
wrk->index = index;
wrk->ctx = cf->ctx;
@@ -740,19 +741,11 @@ rspamd_hard_terminate (struct rspamd_main *rspamd_main)
}
gboolean
-rspamd_worker_is_normal (struct rspamd_worker *w)
+rspamd_worker_is_scanner (struct rspamd_worker *w)
{
- static GQuark normal_quark = (GQuark)0;
if (w) {
- if (normal_quark) {
- return w->type == normal_quark;
- }
- else {
- normal_quark = g_quark_from_static_string ("normal");
- }
-
- return w->type == normal_quark;
+ return !!(w->flags & RSPAMD_WORKER_SCANNER);
}
return FALSE;
diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h
index 14ca3ff2a..179907ee4 100644
--- a/src/libserver/worker_util.h
+++ b/src/libserver/worker_util.h
@@ -147,7 +147,7 @@ void rspamd_hard_terminate (struct rspamd_main *rspamd_main) G_GNUC_NORETURN;
* @param w
* @return
*/
-gboolean rspamd_worker_is_normal (struct rspamd_worker *w);
+gboolean rspamd_worker_is_scanner (struct rspamd_worker *w);
/**
* Creates new session cache