tok = rspamd_mempool_alloc (task->task_pool, sizeof (*tok));
tok->tokenizer = rspamd_stat_get_tokenizer (name);
+ tok->tkcf = cf;
if (tok->tokenizer == NULL) {
return NULL;
tok->config = conf;
tok->conf_len = conf_len;
- tok->tkcf = cf;
tok->tokens = g_tree_new (token_node_compare_func);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_tree_destroy, tok->tokens);
}
cl_runtime->clcf = clcf;
+
bk = rspamd_stat_get_backend (clcf->backend);
if (bk == NULL) {
- msg_warn ("backend of type %s is not defined", clcf->backend);
- cur = g_list_next (cur);
- continue;
+ g_set_error (err, rspamd_stat_quark(), 500,
+ "backend %s is not defined", clcf->backend);
+ g_list_free (cl_runtimes);
+ return NULL;
}
+ cl_runtime->backend = bk;
+
curst = st_list;
while (curst != NULL) {
stcf = (struct rspamd_statfile_config *)curst->data;
return NULL;
}
}
- else {
- if (!cl_runtime->tok->tokenizer->compatible_config (
- cl_runtime->tok, tok_config, conf_len)) {
- g_set_error (err, rspamd_stat_quark(), 500,
- "incompatible tokenizer for statfile %s", stcf->symbol);
- g_list_free (cl_runtimes);
- return NULL;
- }
+ if (!cl_runtime->tok->tokenizer->compatible_config (
+ cl_runtime->tok, tok_config, conf_len)) {
+ g_set_error (err, rspamd_stat_quark(), 500,
+ "incompatible tokenizer for statfile %s", stcf->symbol);
+ g_list_free (cl_runtimes);
+
+ return NULL;
}
st_runtime = rspamd_mempool_alloc0 (task->task_pool,
{
struct rspamd_osb_tokenizer_config *osb_cf;
- if (ptr == NULL) {
+ if (ptr == NULL || len == 0) {
osb_cf = rspamd_tokenizer_osb_config_from_ucl (pool, rt->tkcf->opts);
+
+ if (osb_cf->ht != RSPAMD_OSB_HASH_COMPAT) {
+ /* Trying to load incompatible configuration */
+ msg_err ("cannot load tokenizer configuration from a legacy statfile,"
+ " maybe you have forgotten to set 'compat' option in the "
+ "tokenizer configuration");
+ return FALSE;
+ }
}
else {
g_assert (len == sizeof (*osb_cf));