fixed replicaof no one config, added test case
Former-commit-id: e2615ccf88ddb2a93536b62318983780890c4819
This commit is contained in:
parent
304a037cb3
commit
9d62e397bd
@ -487,7 +487,21 @@ void loadServerConfigFromString(char *config) {
|
|||||||
!strcasecmp(argv[0],"replicaof")) && argc == 3) {
|
!strcasecmp(argv[0],"replicaof")) && argc == 3) {
|
||||||
slaveof_linenum = linenum;
|
slaveof_linenum = linenum;
|
||||||
if (!strcasecmp(argv[1], "no") && !strcasecmp(argv[2], "one")) {
|
if (!strcasecmp(argv[1], "no") && !strcasecmp(argv[2], "one")) {
|
||||||
listRelease(g_pserver->masters);
|
if (listLength(g_pserver->masters)) {
|
||||||
|
listIter li;
|
||||||
|
listNode *ln;
|
||||||
|
listRewind(g_pserver->masters, &li);
|
||||||
|
while ((ln = listNext(&li)))
|
||||||
|
{
|
||||||
|
struct redisMaster *mi = (struct redisMaster*)listNodeValue(ln);
|
||||||
|
zfree(mi->masterauth);
|
||||||
|
zfree(mi->masteruser);
|
||||||
|
zfree(mi->repl_transfer_tmpfile);
|
||||||
|
delete mi->staleKeyMap;
|
||||||
|
zfree(mi);
|
||||||
|
listDelNode(g_pserver->masters, ln);
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
@ -301,3 +301,20 @@ start_server {tags {"active-repl"} overrides {active-replica yes}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_server {tags {"active-repl"} overrides {active-replica yes}} {
|
||||||
|
set master [srv 0 client]
|
||||||
|
set master_host [srv 0 host]
|
||||||
|
set master_port [srv 0 port]
|
||||||
|
test {REPLICAOF no one in config properly clears master list} {
|
||||||
|
start_server [list overrides [list "replicaof" "$master_host $master_port" "replicaof" "no one" "replicaof" "$master_host $master_port"]] {
|
||||||
|
wait_for_condition 50 100 {
|
||||||
|
[string match {*role:slave*} [[srv 0 client] info replication]] &&
|
||||||
|
[string match "*master_host:$master_host*" [[srv 0 client] info replication]] &&
|
||||||
|
[string match "*master_port:$master_port*" [[srv 0 client] info replication]]
|
||||||
|
} else {
|
||||||
|
fail "Replica did not properly connect to master"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user