summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-04-29 14:18:16 +0200
committerantirez <antirez@gmail.com>2011-04-29 14:18:33 +0200
commit9d665825d95aafc72a51eb7dfbbb07719dfeb9a7 (patch)
tree5a8fa7bbe88cbbc293a83d35d7cb1e1482f6de1d
parent19b55f8ebc5692a744e3484b0e2f6a722330dffe (diff)
downloadredis-9d665825d95aafc72a51eb7dfbbb07719dfeb9a7.tar.gz
Fixed a bug with replication where SLAVEOF NO ONE caused a slave to close the connection with its slaves
-rw-r--r--src/networking.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/networking.c b/src/networking.c
index 510ed82ac..9c3a231ea 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -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 */