[sr-dev] git:5.4:78506f7f: db_redis: clean previous connection before trying to reconnect

Victor Seva linuxmaniac at torreviejawireless.org
Tue Mar 15 08:50:34 CET 2022


Module: kamailio
Branch: 5.4
Commit: 78506f7f2dfcdbf2bc9e21168929437516a368bd
URL: https://github.com/kamailio/kamailio/commit/78506f7f2dfcdbf2bc9e21168929437516a368bd

Author: Victor Seva <vseva at sipwise.com>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2022-03-15T08:50:01+01:00

db_redis: clean previous connection before trying to reconnect

(cherry picked from commit 78c8d084e30373aacc456fd41062b68e6e82ea6f)
(cherry picked from commit 2e0537ba306219df0ce71605848e811027c69a57)

---

Modified: src/modules/db_redis/redis_connection.c

---

Diff:  https://github.com/kamailio/kamailio/commit/78506f7f2dfcdbf2bc9e21168929437516a368bd.diff
Patch: https://github.com/kamailio/kamailio/commit/78506f7f2dfcdbf2bc9e21168929437516a368bd.patch

---

diff --git a/src/modules/db_redis/redis_connection.c b/src/modules/db_redis/redis_connection.c
index dd421a7844..d6c24163b1 100644
--- a/src/modules/db_redis/redis_connection.c
+++ b/src/modules/db_redis/redis_connection.c
@@ -112,6 +112,11 @@ int db_redis_connect(km_redis_con_t *con) {
     db = atoi(con->id->database);
     reply = NULL;
 
+    if(con->con) {
+        LM_DBG("free old connection first\n");
+        redisFree(con->con);
+    }
+
     // TODO: introduce require_master mod-param and check if we're indeed master
     // TODO: on carrier, if we have db fail-over, the currently connected
     // redis server will become slave without dropping connections?




More information about the sr-dev mailing list