aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/stat_config.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-22 15:36:49 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-22 15:46:57 +0100
commit924903d8b44eeb3a0f6da670c9ffe598fe736624 (patch)
tree0596d2b634a4be2cae27aa9454a7942f688942ba /src/libstat/stat_config.c
parent164adccd5c4172cdbcddeacde1040a220a3cbdba (diff)
downloadrspamd-924903d8b44eeb3a0f6da670c9ffe598fe736624.tar.gz
rspamd-924903d8b44eeb3a0f6da670c9ffe598fe736624.zip
[Minor] Allow to disable learn cache
Diffstat (limited to 'src/libstat/stat_config.c')
-rw-r--r--src/libstat/stat_config.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 904be726d..9d1e57f13 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -105,6 +105,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
const gchar *cache_name = NULL;
lua_State *L = cfg->lua_state;
guint lua_classifiers_cnt = 0, i;
+ gboolean skip_cache = FALSE;
if (stat_ctx == NULL) {
stat_ctx = g_malloc0 (sizeof (*stat_ctx));
@@ -217,17 +218,22 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
cache_obj = ucl_object_lookup (clf->opts, "cache");
cache_name_obj = NULL;
- if (cache_obj) {
- cache_name_obj = ucl_object_lookup_any (cache_obj,
- "name", "type", NULL);
+ if (cache_obj && ucl_object_type (cache_obj) == UCL_NULL) {
+ skip_cache = TRUE;
}
+ else {
+ if (cache_obj) {
+ cache_name_obj = ucl_object_lookup_any (cache_obj,
+ "name", "type", NULL);
+ }
- if (cache_name_obj) {
- cache_name = ucl_object_tostring (cache_name_obj);
+ if (cache_name_obj) {
+ cache_name = ucl_object_tostring (cache_name_obj);
+ }
}
}
- if (cache_name == NULL) {
+ if (cache_name == NULL && !skip_cache) {
/* We assume that learn cache is the same as backend */
cache_name = clf->backend;
}
@@ -252,7 +258,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
}
/* XXX: bad hack to pass statfiles configuration to cache */
- if (cl->cache == NULL) {
+ if (cl->cache == NULL && !skip_cache) {
cl->cache = rspamd_stat_get_cache (cache_name);
g_assert (cl->cache != NULL);
cl->cachecf = cl->cache->init (stat_ctx, cfg, st, cache_obj);