aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/redis_pool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-28 12:13:52 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-28 12:13:52 +0100
commit72ceee149ff5dc360d1c028689f45840f1f2cf6f (patch)
treea695c337bb5f4089d02d65d2b1c2a4b32cb33967 /src/libserver/redis_pool.c
parent8879db43df630625cb3fb86ff808f83d487ad484 (diff)
downloadrspamd-72ceee149ff5dc360d1c028689f45840f1f2cf6f.tar.gz
rspamd-72ceee149ff5dc360d1c028689f45840f1f2cf6f.zip
[Minor] Allow to close connection to redis without pooling
Issue: #2796
Diffstat (limited to 'src/libserver/redis_pool.c')
-rw-r--r--src/libserver/redis_pool.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c
index 6c74ee6f5..6c168b9d4 100644
--- a/src/libserver/redis_pool.c
+++ b/src/libserver/redis_pool.c
@@ -395,7 +395,7 @@ rspamd_redis_pool_connect (struct rspamd_redis_pool *pool,
void
rspamd_redis_pool_release_connection (struct rspamd_redis_pool *pool,
- struct redisAsyncContext *ctx, gboolean is_fatal)
+ struct redisAsyncContext *ctx, enum rspamd_redis_pool_release_type how)
{
struct rspamd_redis_pool_connection *conn;
@@ -406,24 +406,38 @@ rspamd_redis_pool_release_connection (struct rspamd_redis_pool *pool,
if (conn != NULL) {
g_assert (conn->active);
- if (is_fatal || ctx->err != REDIS_OK) {
+ if (ctx->err != REDIS_OK) {
/* We need to terminate connection forcefully */
- msg_debug_rpool ("closed connection %p forcefully", conn->ctx);
+ msg_debug_rpool ("closed connection %p due to an error", conn->ctx);
REF_RELEASE (conn);
}
else {
- /* 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 %p inactive", conn->ctx);
+ if (how == RSPAMD_REDIS_RELEASE_DEFAULT) {
+ /* 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 %p inactive", conn->ctx);
+ }
+ else {
+ msg_debug_rpool ("closed connection %p due to callbacks left",
+ conn->ctx);
+ REF_RELEASE (conn);
+ }
}
else {
- msg_debug_rpool ("closed connection %p due to callbacks left",
- conn->ctx);
+ if (how == RSPAMD_REDIS_RELEASE_FATAL) {
+ msg_debug_rpool ("closed connection %p due to an fatal termination",
+ conn->ctx);
+ }
+ else {
+ msg_debug_rpool ("closed connection %p due to explicit termination",
+ conn->ctx);
+ }
+
REF_RELEASE (conn);
}
}