From: Vsevolod Stakhov Date: Thu, 16 Jun 2016 11:07:18 +0000 (+0100) Subject: [Fix] Fix redis timeout events handling X-Git-Tag: 1.3.0~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32affb821c02201db7f30c5d8206439932e084be;p=thirdparty%2Frspamd.git [Fix] Fix redis timeout events handling --- diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index a2924d0545..5f6eecdcfb 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -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); }