X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/12ebe2ac17a26ecf263f90b2acdf03db29b00223..3b5e72d402345507856b00bb67a91942f4f1a49d:/src/redis.c diff --git a/src/redis.c b/src/redis.c index 971dfeca..8519f46f 100644 --- a/src/redis.c +++ b/src/redis.c @@ -786,6 +786,7 @@ void initServerConfig() { server.masterport = 6379; server.master = NULL; server.replstate = REDIS_REPL_NONE; + server.repl_serve_stale_data = 1; /* Double constants initialization */ R_Zero = 0.0; @@ -994,6 +995,17 @@ int processCommand(redisClient *c) { return REDIS_OK; } + /* Only allow INFO and SLAVEOF when slave-serve-stale-data is no and + * we are a slave with a broken link with master. */ + if (server.masterhost && server.replstate != REDIS_REPL_CONNECTED && + server.repl_serve_stale_data == 0 && + cmd->proc != infoCommand && cmd->proc != slaveofCommand) + { + addReplyError(c, + "link with MASTER is down and slave-serve-stale-data is set to no"); + return REDIS_OK; + } + /* Exec the command */ if (c->flags & REDIS_MULTI && cmd->proc != execCommand && cmd->proc != discardCommand &&