summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;