diff options
author | John Sully <john@csquare.ca> | 2019-03-09 11:03:59 -0500 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-03-18 11:28:42 +0100 |
commit | 3983dac12bd30ea3dfb54e29ae8e20d3bff95e61 (patch) | |
tree | e847f1464bdb69e57fad6df2f25c716561a07bfc | |
parent | befcbfbe7fe29a32d04ebbc246d2ac5813dbc641 (diff) | |
download | redis-3983dac12bd30ea3dfb54e29ae8e20d3bff95e61.tar.gz |
Replicas aren't allowed to run the replicaof command
-rw-r--r-- | src/replication.c | 8 |
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; |