redisAsyncContext *ctx;
lua_State *L;
struct rspamd_task *task;
+ struct rspamd_redis_pool *pool;
gchar *server;
gchar *reqline;
struct lua_redis_specific_userdata *specific;
ctx->ref.refcount = 100500;
ac = ud->ctx;
ud->ctx = NULL;
- rspamd_redis_pool_release_connection (ud->task->cfg->redis_pool,
- ac, is_successfull);
+ rspamd_redis_pool_release_connection (ud->pool, ac, is_successfull);
ctx->ref.refcount = 0;
is_connected = TRUE;
}
event_del (&sp_ud->timeout);
msg_debug ("finished redis query %p from session %p", sp_ud, ctx);
sp_ud->c->terminated = TRUE;
+ sp_ud->c->task = NULL;
REDIS_RELEASE (ctx);
}
struct lua_redis_userdata *ud = sp_ud->c;
if (!sp_ud->replied) {
- if (sp_ud->cbref != -1) {
+ if (sp_ud->cbref != -1 && ud->task) {
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, sp_ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
}
sp_ud->replied = TRUE;
- if (connected) {
+ if (connected && ud->task) {
rspamd_session_watcher_pop (ud->task->s, sp_ud->w);
rspamd_session_remove_event (ud->task->s, lua_redis_fin, sp_ud);
}
struct lua_redis_userdata *ud = sp_ud->c;
if (!sp_ud->replied) {
- if (sp_ud->cbref != -1) {
+ if (sp_ud->cbref != -1 && ud->task) {
/* Push error */
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, sp_ud->cbref);
ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
}
sp_ud->replied = TRUE;
- rspamd_session_watcher_pop (ud->task->s, sp_ud->w);
- rspamd_session_remove_event (ud->task->s, lua_redis_fin, sp_ud);
+
+ if (ud->task) {
+ rspamd_session_watcher_pop (ud->task->s, sp_ud->w);
+ rspamd_session_remove_event (ud->task->s, lua_redis_fin, sp_ud);
+ }
}
}
ud->ctx = NULL;
if (ac) {
- rspamd_redis_pool_release_connection (ud->task->cfg->redis_pool,
- ac, FALSE);
+ rspamd_redis_pool_release_connection (ud->pool, ac, FALSE);
}
}
* This will call all callbacks pending so the entire context
* will be destructed
*/
- rspamd_redis_pool_release_connection (sp_ud->c->task->cfg->redis_pool,
- ac, TRUE);
+ rspamd_redis_pool_release_connection (sp_ud->c->pool, ac, TRUE);
}
+
REDIS_RELEASE (ctx);
}
ctx->async = TRUE;
ud = &ctx->d.async;
ud->task = task;
+ ud->pool = task->cfg->redis_pool;
ud->L = L;
sp_ud = g_slice_alloc0 (sizeof (*sp_ud));
ctx->async = TRUE;
ud = &ctx->d.async;
ud->task = task;
+ ud->pool = task->cfg->redis_pool;
ud->L = L;
args_pos = 3;
if (ret) {
ud->terminated = 0;
ud->timeout = timeout;
- ud->ctx = rspamd_redis_pool_connect (task->cfg->redis_pool,
+ ud->ctx = rspamd_redis_pool_connect (ud->pool,
dbname, password,
rspamd_inet_address_to_string (addr->addr),
rspamd_inet_address_get_port (addr->addr));
if (ud->ctx) {
msg_err_task_check ("cannot connect to redis: %s",
ud->ctx->errstr);
- rspamd_redis_pool_release_connection (task->cfg->redis_pool,
- ud->ctx, TRUE);
+ rspamd_redis_pool_release_connection (ud->pool, ud->ctx, TRUE);
ud->ctx = NULL;
}
else {
}
else {
msg_info_task_check ("call to redis failed: %s", ud->ctx->errstr);
- rspamd_redis_pool_release_connection (task->cfg->redis_pool,
- ud->ctx, TRUE);
+ rspamd_redis_pool_release_connection (ud->pool, ud->ctx, TRUE);
ud->ctx = NULL;
REDIS_RELEASE (ctx);
ret = FALSE;
ctx->async = TRUE;
ud = &ctx->d.async;
ud->task = task;
+ ud->pool = task->cfg->redis_pool;
ud->L = L;
ret = TRUE;
}
if (ret && ctx) {
ud->terminated = 0;
ud->timeout = timeout;
- ud->ctx = rspamd_redis_pool_connect (task->cfg->redis_pool,
+ ud->ctx = rspamd_redis_pool_connect (ud->pool,
NULL, NULL,
rspamd_inet_address_to_string (addr->addr),
rspamd_inet_address_get_port (addr->addr));