Module: kamailio
Branch: 5.5
Commit: 31e116ccf0ad444cef81d47f123a73038453667a
URL:
https://github.com/kamailio/kamailio/commit/31e116ccf0ad444cef81d47f123a730…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-03-30T12:54:21+02:00
ndb_redis: break on finding a server via sentinel
(cherry picked from commit cc9501663d6dd0fa91aef23ce00a7cdf86319201)
(cherry picked from commit 21fc0e010ef97d86093d7673b5038b2e65f839cb)
---
Modified: src/modules/ndb_redis/redis_client.c
---
Diff:
https://github.com/kamailio/kamailio/commit/31e116ccf0ad444cef81d47f123a730…
Patch:
https://github.com/kamailio/kamailio/commit/31e116ccf0ad444cef81d47f123a730…
---
diff --git a/src/modules/ndb_redis/redis_client.c b/src/modules/ndb_redis/redis_client.c
index ccdff060bfd..fd6e124bdc0 100644
--- a/src/modules/ndb_redis/redis_client.c
+++ b/src/modules/ndb_redis/redis_client.c
@@ -153,6 +153,7 @@ int redisc_init(void)
for(i= 0; i< sentinels_count; i++) {
char *sentinelAddr = sentinels[i];
char *pos;
+ int srvfound = 0;
redisContext *redis;
redisReply *res, *res2;
@@ -174,9 +175,9 @@ int redisc_init(void)
res->element[0]->len + 1);
port = atoi(res->element[1]->str);
LM_DBG("sentinel replied: %s:%d\n", addr, port);
+ srvfound = 1;
}
- }
- else {
+ } else {
res = redisCommand(redis, "SENTINEL slaves %s",
sentinel_group);
if( res && (res->type == REDIS_REPLY_ARRAY) ) {
@@ -198,9 +199,13 @@ int redisc_init(void)
}
LM_DBG("slave for %s: %s:%d\n", sentinel_group,
addr, port);
+ srvfound = 1;
}
}
}
+ if(srvfound==1) {
+ break;
+ }
}
}