summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorresec <resec0109@gmail.com>2019-11-08 16:05:36 +0800
committerresec <resec0109@gmail.com>2019-11-08 16:05:36 +0800
commit14495547dea7e4a0c14cf1507ba7def74b58a4ce (patch)
treeb30833dd886982158a67986bf836f6ebaedddc32 /src
parent95c85692488911c9c8aa1b44027ed2c6b8b7be9c (diff)
downloadrspamd-14495547dea7e4a0c14cf1507ba7def74b58a4ce.tar.gz
rspamd-14495547dea7e4a0c14cf1507ba7def74b58a4ce.zip
[Fix] #3129 Multiple classifiers on redis working incorrectly
Diffstat (limited to 'src')
-rw-r--r--src/libstat/backends/redis_backend.c20
-rw-r--r--src/libstat/learn_cache/redis_cache.c12
2 files changed, 29 insertions, 3 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 08edf1a4f..70011a628 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -1425,13 +1425,29 @@ rspamd_redis_parse_classifier_opts (struct redis_stat_ctx *backend,
elt = ucl_object_lookup (obj, "prefix");
if (elt == NULL || ucl_object_type (elt) != UCL_STRING) {
+ gchar *redis_object;
+
/* Default non-users statistics */
if (backend->enable_users || backend->cbref_user != -1) {
- backend->redis_object = REDIS_DEFAULT_USERS_OBJECT;
+ redis_object = REDIS_DEFAULT_USERS_OBJECT;
}
else {
- backend->redis_object = REDIS_DEFAULT_OBJECT;
+ redis_object = REDIS_DEFAULT_OBJECT;
+ }
+
+ /* Prepend classifier name if defined */
+ elt = ucl_object_lookup (obj, "name");
+ if (elt != NULL && ucl_object_type (elt) == UCL_STRING) {
+ const gchar *cl_name = ucl_object_tostring (elt);
+ gchar *temp;
+ temp = g_malloc (strlen (cl_name) + strlen (redis_object) + 2);
+ strcpy (temp, cl_name);
+ strcat (temp, "_");
+ strcat (temp, redis_object);
+ redis_object = temp;
}
+
+ backend->redis_object = redis_object;
}
else {
/* XXX: sanity check */
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 0df3783ab..320f422dd 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -292,7 +292,17 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx,
cache_ctx->redis_object = ucl_object_tostring (obj);
}
else {
- cache_ctx->redis_object = DEFAULT_REDIS_KEY;
+ gchar *cl_name = st->classifier->cfg->name;
+ if (cl_name) {
+ gchar *redis_object;
+ redis_object = g_malloc (strlen (cl_name) + strlen (DEFAULT_REDIS_KEY) + 2);
+ strcpy (redis_object, cl_name);
+ strcat (redis_object, "_");
+ strcat (redis_object, DEFAULT_REDIS_KEY);
+ cache_ctx->redis_object = redis_object;
+ } else {
+ cache_ctx->redis_object = DEFAULT_REDIS_KEY;
+ }
}
cache_ctx->conf_ref = conf_ref;