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);
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);