]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Set terminated state before calling of async free
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jun 2016 11:44:18 +0000 (12:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jun 2016 11:44:18 +0000 (12:44 +0100)
src/libstat/backends/redis_backend.c

index cb7f0f75b8a45e8b5614f10a282878900721872f..275487a958471d00841dbbf1353f5d1888288ff6 100644 (file)
@@ -904,8 +904,8 @@ rspamd_redis_learned (redisAsyncContext *c, gpointer r, gpointer priv)
        }
 
        if (rt->conn_state == RSPAMD_REDIS_CONNECTED) {
-               redisAsyncFree (rt->redis);
                rt->conn_state = RSPAMD_REDIS_TERMINATED;
+               redisAsyncFree (rt->redis);
        }
 
        REF_RELEASE (rt);
@@ -1236,11 +1236,10 @@ rspamd_redis_finalize_process (struct rspamd_task *task, gpointer runtime,
 
        if (rt->conn_state == RSPAMD_REDIS_CONNECTED) {
                event_del (&rt->timeout_event);
-               redisAsyncFree (rt->redis);
-               rt->redis = NULL;
-
                rt->conn_state = RSPAMD_REDIS_TERMINATED;
 
+               redisAsyncFree (rt->redis);
+               rt->redis = NULL;
                REF_RELEASE (rt);
        }
 }
@@ -1375,10 +1374,9 @@ rspamd_redis_finalize_learn (struct rspamd_task *task, gpointer runtime,
 
        if (rt->conn_state == RSPAMD_REDIS_CONNECTED) {
                event_del (&rt->timeout_event);
+               rt->conn_state = RSPAMD_REDIS_TERMINATED;
                redisAsyncFree (rt->redis);
                rt->redis = NULL;
-
-               rt->conn_state = RSPAMD_REDIS_TERMINATED;
                REF_RELEASE (rt);
        }
 }
@@ -1433,10 +1431,9 @@ rspamd_redis_get_stat (gpointer runtime,
 
                if (rt->redis) {
                        event_del (&rt->timeout_event);
+                       rt->conn_state = RSPAMD_REDIS_TERMINATED;
                        redisAsyncFree (rt->redis);
                        rt->redis = NULL;
-
-                       rt->conn_state = RSPAMD_REDIS_TERMINATED;
                }
 
                if (st->stat) {