]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Prevent race condition in Redis ctx refcounting
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Oct 2018 16:21:16 +0000 (17:21 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Oct 2018 16:21:16 +0000 (17:21 +0100)
src/lua/lua_redis.c

index d3eaa300a24d42b994d89a81cc75ec3b6200f484..5b2ba00624563d2f663c184aa15ac3c78f99b37a 100644 (file)
@@ -480,6 +480,8 @@ lua_redis_push_results (struct lua_redis_ctx *ctx, lua_State *L)
 static void
 lua_redis_cleanup_events (struct lua_redis_ctx *ctx)
 {
+       REDIS_RETAIN (ctx); /* To avoid preliminary destruction */
+
        while (!g_queue_is_empty (ctx->events_cleanup)) {
                struct lua_redis_result *result = g_queue_pop_head (ctx->events_cleanup);
 
@@ -488,6 +490,8 @@ lua_redis_cleanup_events (struct lua_redis_ctx *ctx)
 
                g_free (result);
        }
+
+       REDIS_RELEASE (ctx);
 }
 
 /**