Skip to content

Commit

Permalink
Use best effort address binding to connect to the master
Browse files Browse the repository at this point in the history
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 redis#2609 and redis#2612.
  • Loading branch information
antirez committed Jun 11, 2015
1 parent a017b7e commit 8366907
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
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",
Expand Down

0 comments on commit 8366907

Please sign in to comment.