Skip to content

Commit

Permalink
Fixed a bug with replication where SLAVEOF NO ONE caused a slave to c…
Browse files Browse the repository at this point in the history
…lose the connection with its slaves
  • Loading branch information
antirez committed Apr 29, 2011
1 parent 19b55f8 commit 9d66582
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/networking.c
Expand Up @@ -523,10 +523,16 @@ void freeClient(redisClient *c) {
* close the connection with all our slaves if we have any, so
* when we'll resync with the master the other slaves will sync again
* with us as well. Note that also when the slave is not connected
* to the master it will keep refusing connections by other slaves. */
while (listLength(server.slaves)) {
ln = listFirst(server.slaves);
freeClient((redisClient*)ln->value);
* to the master it will keep refusing connections by other slaves.
*
* We do this only if server.masterhost != NULL. If it is NULL this
* means the user called SLAVEOF NO ONE and we are freeing our
* link with the master, so no need to close link with slaves. */
if (server.masterhost != NULL) {
while (listLength(server.slaves)) {
ln = listFirst(server.slaves);
freeClient((redisClient*)ln->value);
}
}
}
/* Release memory */
Expand Down

0 comments on commit 9d66582

Please sign in to comment.