Browse code

db_redis: fix reconnection failure bug

Richard Fuchs authored on 28/09/2018 21:42:11
Showing 2 changed files
... ...
@@ -392,7 +392,7 @@ void db_redis_free_reply(redisReply **reply) {
392 392
 void db_redis_consume_replies(km_redis_con_t *con) {
393 393
     redisReply *reply = NULL;
394 394
     redis_key_t *query;
395
-    while (con->append_counter > 0 && !con->con->err) {
395
+    while (con->append_counter > 0 && con->con && !con->con->err) {
396 396
         LM_DBG("consuming outstanding reply %u", con->append_counter);
397 397
         db_redis_get_reply(con, (void**)&reply);
398 398
         if (reply) {
... ...
@@ -39,6 +39,8 @@
39 39
     if (!(reply)) { \
40 40
         LM_ERR("Failed to fetch type entry: %s\n", \
41 41
                 (con)->con->errstr); \
42
+        redisFree((con)->con); \
43
+        (con)->con = NULL; \
42 44
         goto err; \
43 45
     } \
44 46
     if ((reply)->type == REDIS_REPLY_ERROR) { \