ignore slaveof no one in redis.conf (#7842)
when slaveof config is "no one", reset any pre-existing config and resume. also solve a memory leak if slaveof appears twice. and fail loading if port number is out of range or not an integer. Co-authored-by: caozhengbin <caozb@yidingyun.com> Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
parent
9bdef76f8e
commit
01694608cb
11
src/config.c
11
src/config.c
@ -473,8 +473,17 @@ void loadServerConfigFromString(char *config) {
|
||||
} else if ((!strcasecmp(argv[0],"slaveof") ||
|
||||
!strcasecmp(argv[0],"replicaof")) && argc == 3) {
|
||||
slaveof_linenum = linenum;
|
||||
sdsfree(server.masterhost);
|
||||
if (!strcasecmp(argv[1], "no") && !strcasecmp(argv[2], "one")) {
|
||||
server.masterhost = NULL;
|
||||
continue;
|
||||
}
|
||||
server.masterhost = sdsnew(argv[1]);
|
||||
server.masterport = atoi(argv[2]);
|
||||
char *ptr;
|
||||
server.masterport = strtol(argv[2], &ptr, 10);
|
||||
if (server.masterport < 0 || server.masterport > 65535 || *ptr != '\0') {
|
||||
err = "Invalid master port"; goto loaderr;
|
||||
}
|
||||
server.repl_state = REPL_STATE_CONNECT;
|
||||
} else if (!strcasecmp(argv[0],"requirepass") && argc == 2) {
|
||||
if (strlen(argv[1]) > CONFIG_AUTHPASS_MAX_LEN) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user