summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-06-11 12:57:53 +0200
committerantirez <antirez@gmail.com>2015-06-11 14:34:38 +0200
commit8366907bed1f8e798889f51ce46c8035a28a6cae (patch)
tree7463e6eab6d7b4b2cf0f6a8ec2b0f19308e79101
parenta017b7ec0e68792fa79b611023f3065c4e0c9394 (diff)
downloadredis-8366907bed1f8e798889f51ce46c8035a28a6cae.tar.gz
Use best effort address binding to connect to the master
We usually want to reach the master using the address of the interface Redis is bound to (via the "bind" config option). That's useful since the master will get (and publish) the slave address getting the peer name of the incoming socket connection from the slave. However, when this is not possible, for example because the slave is bound to the loopback interface but repliaces from a master accessed via an external interface, we want to still connect with the master even from a different interface: in this case it is not really important that the master will provide any other address, while it is vital to be able to replicate correctly. Related to issues #2609 and #2612.
-rw-r--r--src/replication.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/replication.c b/src/replication.c
index ca263527a..c0145b4a1 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1384,7 +1384,7 @@ error:
int connectWithMaster(void) {
int fd;
- fd = anetTcpNonBlockBindConnect(NULL,
+ fd = anetTcpNonBlockBestEffortBindConnect(NULL,
server.masterhost,server.masterport,REDIS_BIND_ADDR);
if (fd == -1) {
redisLog(REDIS_WARNING,"Unable to connect to MASTER: %s",