]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Add additional check to mark redis connection inactive
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 25 Dec 2016 23:16:01 +0000 (23:16 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 25 Dec 2016 23:16:01 +0000 (23:16 +0000)
src/libserver/redis_pool.c
src/lua/lua_redis.c

index 1d42ad3ff90edbf1b0b83aee9b505c66c58da6db..17fa22b1e4445865d526dfd43781411f622c1f9e 100644 (file)
@@ -394,12 +394,19 @@ rspamd_redis_pool_release_connection (struct rspamd_redis_pool *pool,
                        REF_RELEASE (conn);
                }
                else {
-                       /* Just move it to the inactive queue */
-                       g_queue_unlink (conn->elt->active, conn->entry);
-                       g_queue_push_head_link (conn->elt->inactive, conn->entry);
-                       conn->active = FALSE;
-                       rspamd_redis_pool_schedule_timeout (conn);
-                       msg_debug_rpool ("mark connection inactive");
+                       /* Ensure that there are no callbacks attached to this conn */
+                       if (ctx->replies.head == NULL) {
+                               /* Just move it to the inactive queue */
+                               g_queue_unlink (conn->elt->active, conn->entry);
+                               g_queue_push_head_link (conn->elt->inactive, conn->entry);
+                               conn->active = FALSE;
+                               rspamd_redis_pool_schedule_timeout (conn);
+                               msg_debug_rpool ("mark connection inactive");
+                       }
+                       else {
+                               msg_debug_rpool ("closed connection due to callbacks leftover");
+                               REF_RELEASE (conn);
+                       }
                }
 
                REF_RELEASE (conn);
index 3566c7e116971b1ffcf62e2bfa71c170d73ee7c5..7c5e84735a550e92677a2d4c2b661d896ceaff78 100644 (file)
@@ -751,7 +751,7 @@ lua_redis_make_request (lua_State *L)
                                sp_ud->w = NULL;
                        }
 
-                       REDIS_RETAIN (ctx);
+                       REDIS_RETAIN (ctx); /* Cleared by fin event */
                        ctx->cmds_pending ++;
                        double_to_tv (timeout, &tv);
                        event_set (&sp_ud->timeout, -1, EV_TIMEOUT, lua_redis_timeout, sp_ud);