Module: kamailio
Branch: 5.6
Commit: 21fc0e010ef97d86093d7673b5038b2e65f839cb
URL:
https://github.com/kamailio/kamailio/commit/21fc0e010ef97d86093d7673b5038b2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-03-30T12:53:12+02:00
ndb_redis: break on finding a server via sentinel
(cherry picked from commit cc9501663d6dd0fa91aef23ce00a7cdf86319201)
---
Modified: src/modules/ndb_redis/redis_client.c
---
Diff:
https://github.com/kamailio/kamailio/commit/21fc0e010ef97d86093d7673b5038b2…
Patch:
https://github.com/kamailio/kamailio/commit/21fc0e010ef97d86093d7673b5038b2…
---
diff --git a/src/modules/ndb_redis/redis_client.c b/src/modules/ndb_redis/redis_client.c
index c26154930b9..88a13477758 100644
--- a/src/modules/ndb_redis/redis_client.c
+++ b/src/modules/ndb_redis/redis_client.c
@@ -155,6 +155,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;
@@ -176,9 +177,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) ) {
@@ -200,9 +201,13 @@ int redisc_init(void)
}
LM_DBG("slave for %s: %s:%d\n", sentinel_group,
addr, port);
+ srvfound = 1;
}
}
}
+ if(srvfound==1) {
+ break;
+ }
}
}