Cluster: fix error reporting when slaveof is found in config.

This commit is contained in:
antirez 2014-01-20 11:08:14 +01:00
parent ac3850cabd
commit 437fc2cb56

View File

@ -82,6 +82,7 @@ void resetServerSaveParams() {
void loadServerConfigFromString(char *config) {
char *err = NULL;
int linenum = 0, totlines, i;
int slaveof_linenum = 0;
sds *lines;
lines = sdssplitlen(config,strlen(config),"\n",1,&totlines);
@ -244,6 +245,7 @@ void loadServerConfigFromString(char *config) {
goto loaderr;
}
} else if (!strcasecmp(argv[0],"slaveof") && argc == 3) {
slaveof_linenum = linenum;
server.masterhost = sdsnew(argv[1]);
server.masterport = atoi(argv[2]);
server.repl_state = REDIS_REPL_CONNECT;
@ -490,13 +492,16 @@ void loadServerConfigFromString(char *config) {
}
sdsfreesplitres(argv,argc);
}
sdsfreesplitres(lines,totlines);
/* Sanity checks. */
if (server.cluster_enabled && server.masterhost) {
linenum = slaveof_linenum;
i = linenum-1;
err = "slaveof directive not allowed in cluster mode";
goto loaderr;
}
sdsfreesplitres(lines,totlines);
return;
loaderr: