Module: kamailio
Branch: master
Commit: 7cec977f8e12bbeb0309d903e02461d1ccbf41a8
URL:
https://github.com/kamailio/kamailio/commit/7cec977f8e12bbeb0309d903e02461d…
Author: FredWH <wh720(a)139.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-08-02T15:00:18+02:00
db_redis: fix broken pipe issue, if redis server with timeout setting.
- issue #2764
---
Modified: src/modules/db_redis/redis_connection.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7cec977f8e12bbeb0309d903e02461d…
Patch:
https://github.com/kamailio/kamailio/commit/7cec977f8e12bbeb0309d903e02461d…
---
diff --git a/src/modules/db_redis/redis_connection.c
b/src/modules/db_redis/redis_connection.c
index ad2921f1d5..dd421a7844 100644
--- a/src/modules/db_redis/redis_connection.c
+++ b/src/modules/db_redis/redis_connection.c
@@ -305,7 +305,8 @@ void *db_redis_command_argv(km_redis_con_t *con, redis_key_t *query)
{
LM_DBG("query has %d args\n", argc);
redisReply *reply = redisCommandArgv(con->con, argc, (const char**)argv, NULL);
- if (con->con->err == REDIS_ERR_EOF) {
+ if (con->con->err != REDIS_OK) {
+ LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n",
con->con->err, con->con->errstr);
if (db_redis_connect(con) != 0) {
LM_ERR("Failed to reconnect to redis db\n");
pkg_free(argv);
@@ -344,7 +345,8 @@ int db_redis_append_command_argv(km_redis_con_t *con, redis_key_t
*query, int qu
// this should actually never happen, because if all replies
// are properly consumed for the previous command, it won't send
// out a new query until redisGetReply is called
- if (con->con->err == REDIS_ERR_EOF) {
+ if (con->con->err != REDIS_OK) {
+ LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n",
con->con->err, con->con->errstr);
if (db_redis_connect(con) != 0) {
LM_ERR("Failed to reconnect to redis db\n");
pkg_free(argv);
@@ -374,8 +376,8 @@ int db_redis_get_reply(km_redis_con_t *con, void **reply) {
*reply = NULL;
ret = redisGetReply(con->con, reply);
- if (con->con->err == REDIS_ERR_EOF) {
- LM_DBG("redis connection is gone, try reconnect\n");
+ if (con->con->err != REDIS_OK) {
+ LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n",
con->con->err, con->con->errstr);
con->append_counter = 0;
if (db_redis_connect(con) != 0) {
LM_ERR("Failed to reconnect to redis db\n");
@@ -396,7 +398,7 @@ int db_redis_get_reply(km_redis_con_t *con, void **reply) {
db_redis_key_free(&query);
}
ret = redisGetReply(con->con, reply);
- if (con->con->err != REDIS_ERR_EOF) {
+ if (con->con->err == REDIS_OK) {
con->append_counter--;
}
} else {