Module: kamailio
Branch: master
Commit: cc9501663d6dd0fa91aef23ce00a7cdf86319201
URL:
https://github.com/kamailio/kamailio/commit/cc9501663d6dd0fa91aef23ce00a7cd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-03-28T08:12:00+02:00
ndb_redis: break on finding a server via sentinel
---
Modified: src/modules/ndb_redis/redis_client.c
---
Diff:
https://github.com/kamailio/kamailio/commit/cc9501663d6dd0fa91aef23ce00a7cd…
Patch:
https://github.com/kamailio/kamailio/commit/cc9501663d6dd0fa91aef23ce00a7cd…
---
diff --git a/src/modules/ndb_redis/redis_client.c b/src/modules/ndb_redis/redis_client.c
index d6b7e0b95b9..a3ee1c332d4 100644
--- a/src/modules/ndb_redis/redis_client.c
+++ b/src/modules/ndb_redis/redis_client.c
@@ -156,6 +156,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;
@@ -177,9 +178,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) ) {
@@ -201,9 +202,13 @@ int redisc_init(void)
}
LOG(ndb_redis_debug, "slave for %s: %s:%d\n",
sentinel_group, addr, port);
+ srvfound = 1;
}
}
}
+ if(srvfound==1) {
+ break;
+ }
}
}