aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-09 12:32:17 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-09 12:32:17 +0100
commit61e083db79ed2ad7ebec73003c5787ffb1e1a25f (patch)
tree48d4e3d26590b2b4cc2322ea57ee15405f0500f5
parent48bf70c3c212e96d0a3a9a34a460c0bd0aed2d33 (diff)
downloadrspamd-61e083db79ed2ad7ebec73003c5787ffb1e1a25f.tar.gz
rspamd-61e083db79ed2ad7ebec73003c5787ffb1e1a25f.zip
[Fix] More fixes for redis refcounts
-rw-r--r--src/libstat/backends/redis_backend.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index ea852566e..d7725a4c1 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -680,9 +680,9 @@ rspamd_redis_fin (gpointer data)
if (rt->conn_state != RSPAMD_REDIS_CONNECTED) {
rt->conn_state = RSPAMD_REDIS_DISCONNECTED;
+ event_del (&rt->timeout_event);
+ REF_RELEASE (rt);
}
-
- event_del (&rt->timeout_event);
}
static void
@@ -692,9 +692,9 @@ rspamd_redis_fin_learn (gpointer data)
if (rt->conn_state != RSPAMD_REDIS_CONNECTED) {
rt->conn_state = RSPAMD_REDIS_DISCONNECTED;
+ event_del (&rt->timeout_event);
+ REF_RELEASE (rt);
}
-
- event_del (&rt->timeout_event);
}
static void
@@ -705,12 +705,13 @@ rspamd_redis_timeout (gint fd, short what, gpointer d)
task = rt->task;
- msg_err_task ("connection to redis server %s timed out",
+ msg_err_task_check ("connection to redis server %s timed out",
rspamd_upstream_name (rt->selected));
rspamd_upstream_fail (rt->selected);
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 */
@@ -1148,6 +1149,8 @@ rspamd_redis_runtime (struct rspamd_task *task,
event_base_set (task->ev_base, &rt->timeout_event);
double_to_tv (ctx->timeout, &tv);
event_add (&rt->timeout_event, &tv);
+ /* Cleared by timeout */
+ REF_RETAIN (rt);
rspamd_redis_maybe_auth (ctx, rt->redis);
redisAsyncCommand (rt->redis, rspamd_redis_connected, rt, "HGET %s %s",