aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/fuzzy_backend_redis.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-17 13:35:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-17 14:09:51 +0000
commitdeb0241180eb94d393c54659e21ebdc66d9b712f (patch)
tree28384c86102be32bb204fb48fbc27147a1ecccbc /src/libserver/fuzzy_backend_redis.c
parent46b0dbbc25618bcf2e58e1209b5d1f41c8dcdaa0 (diff)
downloadrspamd-deb0241180eb94d393c54659e21ebdc66d9b712f.tar.gz
rspamd-deb0241180eb94d393c54659e21ebdc66d9b712f.zip
[Fix] Break pool connection on fatal redis errors
MFH: true
Diffstat (limited to 'src/libserver/fuzzy_backend_redis.c')
-rw-r--r--src/libserver/fuzzy_backend_redis.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/libserver/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend_redis.c
index 0ab646131..f6ca12130 100644
--- a/src/libserver/fuzzy_backend_redis.c
+++ b/src/libserver/fuzzy_backend_redis.c
@@ -103,7 +103,8 @@ rspamd_fuzzy_redis_session_free_args (struct rspamd_fuzzy_redis_session *session
}
}
static void
-rspamd_fuzzy_redis_session_dtor (struct rspamd_fuzzy_redis_session *session)
+rspamd_fuzzy_redis_session_dtor (struct rspamd_fuzzy_redis_session *session,
+ gboolean is_fatal)
{
redisAsyncContext *ac;
@@ -112,7 +113,7 @@ rspamd_fuzzy_redis_session_dtor (struct rspamd_fuzzy_redis_session *session)
ac = session->ctx;
session->ctx = NULL;
rspamd_redis_pool_release_connection (session->backend->pool,
- ac, FALSE);
+ ac, is_fatal);
}
if (event_get_base (&session->timeout)) {
@@ -423,7 +424,7 @@ rspamd_fuzzy_redis_shingles_callback (redisAsyncContext *c, gpointer r,
session->callback.cb_check (&rep, session->cbdata);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
}
else {
/* Add timeout */
@@ -456,7 +457,7 @@ rspamd_fuzzy_redis_shingles_callback (redisAsyncContext *c, gpointer r,
rspamd_upstream_fail (session->up);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, FALSE);
}
static void
@@ -500,7 +501,7 @@ rspamd_fuzzy_backend_check_shingles (struct rspamd_fuzzy_redis_session *session)
session->callback.cb_check (&rep, session->cbdata);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
}
else {
/* Add timeout */
@@ -581,7 +582,7 @@ rspamd_fuzzy_redis_check_callback (redisAsyncContext *c, gpointer r,
rspamd_upstream_fail (session->up);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, FALSE);
}
void
@@ -642,7 +643,7 @@ rspamd_fuzzy_backend_check_redis (struct rspamd_fuzzy_backend *bk,
rspamd_inet_address_get_port (addr));
if (session->ctx == NULL) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
memset (&rep, 0, sizeof (rep));
@@ -653,7 +654,7 @@ rspamd_fuzzy_backend_check_redis (struct rspamd_fuzzy_backend *bk,
if (redisAsyncCommandArgv (session->ctx, rspamd_fuzzy_redis_check_callback,
session, session->nargs,
(const gchar **)session->argv, session->argv_lens) != REDIS_OK) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
memset (&rep, 0, sizeof (rep));
@@ -714,7 +715,7 @@ rspamd_fuzzy_redis_count_callback (redisAsyncContext *c, gpointer r,
rspamd_upstream_fail (session->up);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, FALSE);
}
void
@@ -765,7 +766,7 @@ rspamd_fuzzy_backend_count_redis (struct rspamd_fuzzy_backend *bk,
rspamd_inet_address_get_port (addr));
if (session->ctx == NULL) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
cb (0, ud);
@@ -775,7 +776,7 @@ rspamd_fuzzy_backend_count_redis (struct rspamd_fuzzy_backend *bk,
if (redisAsyncCommandArgv (session->ctx, rspamd_fuzzy_redis_count_callback,
session, session->nargs,
(const gchar **)session->argv, session->argv_lens) != REDIS_OK) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
cb (0, ud);
@@ -835,7 +836,7 @@ rspamd_fuzzy_redis_version_callback (redisAsyncContext *c, gpointer r,
rspamd_upstream_fail (session->up);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, FALSE);
}
void
@@ -887,7 +888,7 @@ rspamd_fuzzy_backend_version_redis (struct rspamd_fuzzy_backend *bk,
rspamd_inet_address_get_port (addr));
if (session->ctx == NULL) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
cb (0, ud);
@@ -897,7 +898,7 @@ rspamd_fuzzy_backend_version_redis (struct rspamd_fuzzy_backend *bk,
if (redisAsyncCommandArgv (session->ctx, rspamd_fuzzy_redis_version_callback,
session, session->nargs,
(const gchar **)session->argv, session->argv_lens) != REDIS_OK) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
cb (0, ud);
@@ -1206,7 +1207,7 @@ rspamd_fuzzy_redis_update_callback (redisAsyncContext *c, gpointer r,
rspamd_upstream_fail (session->up);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, FALSE);
}
void
@@ -1313,7 +1314,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
rspamd_inet_address_get_port (addr));
if (session->ctx == NULL) {
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
cb (FALSE, ud);
@@ -1332,7 +1333,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
if (cb) {
cb (FALSE, ud);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
return;
}
@@ -1348,7 +1349,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
if (cb) {
cb (FALSE, ud);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
return;
}
@@ -1371,7 +1372,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
if (cb) {
cb (FALSE, ud);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
return;
}
@@ -1389,7 +1390,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
if (cb) {
cb (FALSE, ud);
}
- rspamd_fuzzy_redis_session_dtor (session);
+ rspamd_fuzzy_redis_session_dtor (session, TRUE);
return;
}