Browse Source

db_redis: fix reconnection failure bug

Richard Fuchs 7 years ago
parent
commit
6daafa0c83

+ 1 - 1
src/modules/db_redis/redis_connection.c

@@ -392,7 +392,7 @@ void db_redis_free_reply(redisReply **reply) {
 void db_redis_consume_replies(km_redis_con_t *con) {
     redisReply *reply = NULL;
     redis_key_t *query;
-    while (con->append_counter > 0 && !con->con->err) {
+    while (con->append_counter > 0 && con->con && !con->con->err) {
         LM_DBG("consuming outstanding reply %u", con->append_counter);
         db_redis_get_reply(con, (void**)&reply);
         if (reply) {

+ 2 - 0
src/modules/db_redis/redis_connection.h

@@ -39,6 +39,8 @@
     if (!(reply)) { \
         LM_ERR("Failed to fetch type entry: %s\n", \
                 (con)->con->errstr); \
+        redisFree((con)->con); \
+        (con)->con = NULL; \
         goto err; \
     } \
     if ((reply)->type == REDIS_REPLY_ERROR) { \