MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / findReplica

Function findReplica

src/replication.cpp:5037–5059  ·  view source on GitHub ↗

Find replica at IP:PORT from replica list */

Source from the content-addressed store, hash-verified

5035
5036/* Find replica at IP:PORT from replica list */
5037static client *findReplica(char *host, int port) {
5038 listIter li;
5039 listNode *ln;
5040 client *replica;
5041
5042 listRewind(g_pserver->slaves,&li);
5043 while((ln = listNext(&li))) {
5044 replica = (client*)listNodeValue(ln);
5045 char ip[NET_IP_STR_LEN], *replicaip = replica->slave_addr;
5046
5047 if (!replicaip) {
5048 if (connPeerToString(replica->conn, ip, sizeof(ip), NULL) == -1)
5049 continue;
5050 replicaip = ip;
5051 }
5052
5053 if (!strcasecmp(host, replicaip) &&
5054 (port == replica->slave_listening_port))
5055 return replica;
5056 }
5057
5058 return NULL;
5059}
5060
5061const char *getFailoverStateString() {
5062 switch(g_pserver->failover_state) {

Callers 2

failoverCommandFunction · 0.85
updateFailoverStatusFunction · 0.85

Calls 3

listRewindFunction · 0.85
listNextFunction · 0.85
connPeerToStringFunction · 0.85

Tested by

no test coverage detected