diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-05 14:55:52 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-05 14:55:52 +0000 |
commit | 15d023291bedb5cbd2634c05f79185ab6a358c6c (patch) | |
tree | ea992b967d7f13a4d3bbb1d29d27cebf7f9e1bf4 /src/libstat/backends | |
parent | 9f754e6c7738f2d0b136c07bf4ac8060888cb3b4 (diff) | |
download | rspamd-15d023291bedb5cbd2634c05f79185ab6a358c6c.tar.gz rspamd-15d023291bedb5cbd2634c05f79185ab6a358c6c.zip |
[Minor] Few more fixes
Diffstat (limited to 'src/libstat/backends')
-rw-r--r-- | src/libstat/backends/redis_backend.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index 57cf059d8..f5c032429 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -32,8 +32,6 @@ INIT_LOG_MODULE(stat_redis) #define REDIS_CTX(p) (struct redis_stat_ctx *) (p) #define REDIS_RUNTIME(p) (struct redis_stat_runtime *) (p) -#define REDIS_BACKEND_TYPE "redis" -#define REDIS_DEFAULT_PORT 6379 #define REDIS_DEFAULT_OBJECT "%s%l" #define REDIS_DEFAULT_USERS_OBJECT "%s%l%r" #define REDIS_DEFAULT_TIMEOUT 0.5 @@ -63,7 +61,7 @@ struct redis_stat_runtime { struct redis_stat_ctx *ctx; struct rspamd_task *task; struct rspamd_statfile_config *stcf; - GArray *results; + GPtrArray *tokens; gchar *redis_object_expanded; guint64 learned; gint id; @@ -1080,6 +1078,10 @@ rspamd_redis_fin(gpointer data) if (rt->err) { g_error_free(rt->err); } + + if (rt->tokens) { + g_ptr_array_unref(rt->tokens); + } } @@ -1268,7 +1270,6 @@ rspamd_redis_runtime(struct rspamd_task *task, struct redis_stat_ctx *ctx = REDIS_CTX(c); struct redis_stat_runtime *rt; char *object_expanded = NULL; - rspamd_inet_addr_t *addr; g_assert(ctx != NULL); g_assert(stcf != NULL); @@ -1282,6 +1283,9 @@ rspamd_redis_runtime(struct rspamd_task *task, return NULL; } + /* Look for the cached results */ + + rt = rspamd_mempool_alloc0(task->task_pool, sizeof(*rt)); rt->task = task; rt->ctx = ctx; @@ -1356,6 +1360,21 @@ rspamd_redis_classified(lua_State *L) struct rspamd_task *task = lua_check_task(L, 1); struct redis_stat_runtime *rt = REDIS_RUNTIME(rspamd_mempool_get_variable(task->task_pool, cookie)); /* TODO: write it */ + + if (rt == NULL) { + msg_err_task("internal error: cannot find runtime for cookie %s", cookie); + + return 0; + } + + bool result = lua_toboolean(L, 2); + + if (result) { + } + else { + } + + return 0; } gboolean @@ -1408,6 +1427,8 @@ rspamd_redis_process_tokens(struct rspamd_task *task, return FALSE; } + rt->tokens = g_ptr_array_ref(tokens); + lua_settop(L, err_idx - 1); return TRUE; } |