Find replica at IP:PORT from replica list */
| 3523 | |
| 3524 | /* Find replica at IP:PORT from replica list */ |
| 3525 | static 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 | |
| 3549 | const char *getFailoverStateString() { |
| 3550 | switch(server.failover_state) { |
no test coverage detected