]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix redis timeout events handling
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jun 2016 11:07:18 +0000 (12:07 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jun 2016 11:07:18 +0000 (12:07 +0100)
src/libstat/backends/redis_backend.c

index a2924d05452daa6b3681c30d702b762c2ad52149..5f6eecdcfb01558fd6998b55d483c943a9131328 100644 (file)
@@ -705,17 +705,19 @@ rspamd_redis_timeout (gint fd, short what, gpointer d)
 
        task = rt->task;
 
+       REF_RETAIN (rt);
        msg_err_task_check ("connection to redis server %s timed out",
                        rspamd_upstream_name (rt->selected));
        rspamd_upstream_fail (rt->selected);
 
-       if (rt->conn_state != RSPAMD_REDIS_CONNECTED) {
+       if (rt->conn_state == RSPAMD_REDIS_CONNECTED) {
                rspamd_session_remove_event (task->s, rspamd_redis_fin, rt);
        }
 
        rt->conn_state = RSPAMD_REDIS_TIMEDOUT;
        redisAsyncFree (rt->redis);
        rt->redis = NULL;
+       REF_RELEASE (rt);
 }
 
 /* Called when we have connected to the redis server and got stats */
@@ -1088,6 +1090,10 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx,
 static void
 rspamd_redis_runtime_dtor (struct redis_stat_runtime *rt)
 {
+       if (event_get_base (&rt->timeout_event)) {
+               event_del (&rt->timeout_event);
+       }
+
        g_slice_free1 (sizeof (*rt), rt);
 }