aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-17 16:07:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-17 16:07:48 +0100
commit9cfe6f018bb6a5467bd030171d40684603fabb8b (patch)
tree11aec99f795c6874bf425ec9638628b292c4693c /src/libstat
parent39b7f7a564cd8c9c99fe785373ba943554ef6f14 (diff)
downloadrspamd-9cfe6f018bb6a5467bd030171d40684603fabb8b.tar.gz
rspamd-9cfe6f018bb6a5467bd030171d40684603fabb8b.zip
[Fix] Fix redis timeouts processing logic
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/backends/redis_backend.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index e83fc3e46..0b26f39c7 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -66,6 +66,7 @@ struct redis_stat_runtime {
redisAsyncContext *redis;
guint64 learned;
gint id;
+ gboolean has_event;
};
/* Used to get statistics from redis */
@@ -679,6 +680,7 @@ rspamd_redis_fin (gpointer data)
struct redis_stat_runtime *rt = REDIS_RUNTIME (data);
redisAsyncContext *redis;
+ rt->has_event = FALSE;
/* Stop timeout */
if (event_get_base (&rt->timeout_event)) {
event_del (&rt->timeout_event);
@@ -698,6 +700,7 @@ rspamd_redis_fin_learn (gpointer data)
struct redis_stat_runtime *rt = REDIS_RUNTIME (data);
redisAsyncContext *redis;
+ rt->has_event = FALSE;
/* Stop timeout */
if (event_get_base (&rt->timeout_event)) {
event_del (&rt->timeout_event);
@@ -859,7 +862,7 @@ rspamd_redis_processed (redisAsyncContext *c, gpointer r, gpointer priv)
}
}
- if (rt->redis) {
+ if (rt->has_event) {
rspamd_session_remove_event (task->s, rspamd_redis_fin, rt);
}
}
@@ -885,7 +888,7 @@ rspamd_redis_learned (redisAsyncContext *c, gpointer r, gpointer priv)
}
}
- if (rt->redis) {
+ if (rt->has_event) {
rspamd_session_remove_event (task->s, rspamd_redis_fin_learn, rt);
}
}
@@ -1164,6 +1167,7 @@ rspamd_redis_process_tokens (struct rspamd_task *task,
rspamd_session_add_event (task->s, rspamd_redis_fin, rt,
rspamd_redis_stat_quark ());
+ rt->has_event = TRUE;
if (event_get_base (&rt->timeout_event)) {
event_del (&rt->timeout_event);
@@ -1311,6 +1315,7 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens,
if (ret == REDIS_OK) {
rspamd_session_add_event (task->s, rspamd_redis_fin_learn, rt,
rspamd_redis_stat_quark ());
+ rt->has_event = TRUE;
/* Set timeout */
if (event_get_base (&rt->timeout_event)) {
event_del (&rt->timeout_event);