summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sully <john@csquare.ca>2019-03-09 11:03:59 -0500
committerantirez <antirez@gmail.com>2019-03-18 11:28:42 +0100
commit3983dac12bd30ea3dfb54e29ae8e20d3bff95e61 (patch)
treee847f1464bdb69e57fad6df2f25c716561a07bfc
parentbefcbfbe7fe29a32d04ebbc246d2ac5813dbc641 (diff)
downloadredis-3983dac12bd30ea3dfb54e29ae8e20d3bff95e61.tar.gz
Replicas aren't allowed to run the replicaof command
-rw-r--r--src/replication.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/replication.c b/src/replication.c
index 8d9bcfbf0..6d7a51c07 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1793,6 +1793,14 @@ void slaveofCommand(client *c) {
} else {
long port;
+ if (c->flags & CLIENT_SLAVE)
+ {
+ /* If a client is already a replica they cannot run this command,
+ * because it involves flushing all replicas (including this client) */
+ addReplyError(c, "Command is not valid when client is a replica.");
+ return;
+ }
+
if ((getLongFromObjectOrReply(c, c->argv[2], &port, NULL) != C_OK))
return;