MCPcopy Create free account
hub / github.com/F-Stack/f-stack / findReplica

Function findReplica

app/redis-6.2.6/src/replication.c:3525–3547  ·  view source on GitHub ↗

Find replica at IP:PORT from replica list */

Source from the content-addressed store, hash-verified

3523
3524/* Find replica at IP:PORT from replica list */
3525static client *findReplica(char *host, int port) {
3526 listIter li;
3527 listNode *ln;
3528 client *replica;
3529
3530 listRewind(server.slaves,&li);
3531 while((ln = listNext(&li))) {
3532 replica = ln->value;
3533 char ip[NET_IP_STR_LEN], *replicaip = replica->slave_addr;
3534
3535 if (!replicaip) {
3536 if (connPeerToString(replica->conn, ip, sizeof(ip), NULL) == -1)
3537 continue;
3538 replicaip = ip;
3539 }
3540
3541 if (!strcasecmp(host, replicaip) &&
3542 (port == replica->slave_listening_port))
3543 return replica;
3544 }
3545
3546 return NULL;
3547}
3548
3549const char *getFailoverStateString() {
3550 switch(server.failover_state) {

Callers 2

failoverCommandFunction · 0.85
updateFailoverStatusFunction · 0.85

Calls 4

listRewindFunction · 0.85
listNextFunction · 0.85
connPeerToStringFunction · 0.85
strcasecmpFunction · 0.85

Tested by

no test coverage detected