diff options
author | John Sully <john@csquare.ca> | 2019-03-09 11:03:59 -0500 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-03-10 09:52:19 +0100 |
commit | 39ccce033a08740562b48a3e39746beabfbe6e38 (patch) | |
tree | 6e538a0c3f008967e83392c3f65f793fc7a370e9 | |
parent | 825843db9e6c63565695c8c77bb8cffc49cee252 (diff) | |
download | redis-39ccce033a08740562b48a3e39746beabfbe6e38.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 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; |