summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sully <john@csquare.ca>2019-03-09 11:03:59 -0500
committerantirez <antirez@gmail.com>2019-03-10 09:52:19 +0100
commit39ccce033a08740562b48a3e39746beabfbe6e38 (patch)
tree6e538a0c3f008967e83392c3f65f793fc7a370e9
parent825843db9e6c63565695c8c77bb8cffc49cee252 (diff)
downloadredis-39ccce033a08740562b48a3e39746beabfbe6e38.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 2c0c47a27..f442d86d6 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -2023,6 +2023,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;