Module: kamailio
Branch: master
Commit: b14044fac93ef4b43584dd0e14f2b985d41745d6
URL:
https://github.com/kamailio/kamailio/commit/b14044fac93ef4b43584dd0e14f2b98…
Author: PertsevRoman <pertsev.roman(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-11-20T09:11:14+01:00
db_redis: fix: hiredis-cluster build fix
- fixed preprocessing issues if WITH_HIREDIS_CLUSTER specified
- GH #4015
---
Modified: src/modules/db_redis/Makefile
Modified: src/modules/db_redis/redis_connection.h
Modified: src/modules/db_redis/redis_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b14044fac93ef4b43584dd0e14f2b98…
Patch:
https://github.com/kamailio/kamailio/commit/b14044fac93ef4b43584dd0e14f2b98…
---
diff --git a/src/modules/db_redis/Makefile b/src/modules/db_redis/Makefile
index 85d9b9a956f..d5e304cc28c 100644
--- a/src/modules/db_redis/Makefile
+++ b/src/modules/db_redis/Makefile
@@ -64,9 +64,9 @@ ifneq ($(HIREDIS_CLUSTER_BUILDER),)
HIREDISCLUSTERDEFS = $(shell $(HIREDIS_CLUSTER_BUILDER) --cflags)
HIREDISCLUSTERLIBS = $(shell $(HIREDIS_CLUSTER_BUILDER) --libs)
HIREDISCLUSTERLIBSPATH = $(shell $(HIREDIS_CLUSTER_BUILDER) --libs-only-L | cut -c 3-)
- ifneq ($(shell ls $(HIREDISCLUSTERLIBSPATH) | grep libhiredis_ssl.so),)
+ ifneq ($(shell ls $(HIREDISCLUSTERLIBSPATH) | grep libhiredis_cluster_ssl.so),)
HIREDISCLUSTERDEFS += -DWITH_SSL
- HIREDISCLUSTERLIBS += -lhiredis_ssl
+ HIREDISCLUSTERLIBS += -lhiredis_cluster_ssl
endif
DEFS+=-DWITH_HIREDIS_CLUSTER
DEFS+=$(HIREDISCLUSTERDEFS)
diff --git a/src/modules/db_redis/redis_connection.h
b/src/modules/db_redis/redis_connection.h
index 62bb81f40f2..5b6f819c08b 100644
--- a/src/modules/db_redis/redis_connection.h
+++ b/src/modules/db_redis/redis_connection.h
@@ -25,6 +25,9 @@
#ifdef WITH_HIREDIS_CLUSTER
#include <hircluster.h>
+#ifdef WITH_SSL
+#include <hircluster_ssl.h>
+#endif
#else
#ifdef WITH_HIREDIS_PATH
#include <hiredis/hiredis.h>
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
index b3624975cf4..062911b2e10 100644
--- a/src/modules/db_redis/redis_dbase.c
+++ b/src/modules/db_redis/redis_dbase.c
@@ -1020,43 +1020,51 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
#endif
#ifdef WITH_HIREDIS_CLUSTER
+ return 0;
+err:
+ if(reply)
+ db_redis_free_reply(&reply);
+ return -1;
}
-#endif
+#else
-// for full table scans, we have to manually match all given keys
-// but only do this once for repeated invocations
-if(!*manual_keys) {
- *manual_keys_count = _n;
- *manual_keys = (int *)pkg_malloc(*manual_keys_count * sizeof(int));
- if(!*manual_keys) {
- LM_ERR("Failed to allocate memory for manual keys\n");
- goto err;
- }
- memset(*manual_keys, 0, *manual_keys_count * sizeof(int));
- for(l = 0; l < _n; ++l) {
- (*manual_keys)[l] = l;
- }
-}
+ // for full table scans, we have to manually match all given keys
+ // but only do this once for repeated invocations
+ if(!*manual_keys) {
+ *manual_keys_count = _n;
+ *manual_keys = (int *)pkg_malloc(*manual_keys_count * sizeof(int));
+ if(!*manual_keys) {
+ LM_ERR("Failed to allocate memory for manual keys\n");
+ goto err;
+ }
+ memset(*manual_keys, 0, *manual_keys_count * sizeof(int));
+ for(l = 0; l < _n; ++l) {
+ (*manual_keys)[l] = l;
+ }
+ }
-if(reply) {
- db_redis_free_reply(&reply);
-}
+ if(reply) {
+ db_redis_free_reply(&reply);
+ }
-db_redis_key_free(&query_v);
+ db_redis_key_free(&query_v);
-LM_DBG("got %lu entries by scan\n", (unsigned long)i);
-return 0;
+ LM_DBG("got %lu entries by scan\n", (unsigned long)i);
+ return 0;
-err : if(reply) db_redis_free_reply(&reply);
-db_redis_key_free(&query_v);
-db_redis_key_free(query_keys);
-*query_keys_count = 0;
-if(*manual_keys) {
- pkg_free(*manual_keys);
- *manual_keys = NULL;
-}
-return -1;
-}
+ err:
+ if(reply)
+ db_redis_free_reply(&reply);
+ db_redis_key_free(&query_v);
+ db_redis_key_free(query_keys);
+ *query_keys_count = 0;
+ if(*manual_keys) {
+ pkg_free(*manual_keys);
+ *manual_keys = NULL;
+ }
+ return -1;
+ }
+#endif
static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
const int _n, redis_key_t **query_keys, int *query_keys_count,