raft: fix configuration::can_vote() to worth correctly with joint config

Fix configuration::can_vote() to return true if a node is a voting
member in any of the configs.
This commit is contained in:
Gleb Natapov
2021-11-16 15:38:56 +02:00
parent 32e62252e1
commit 8f64a6d2d2

View File

@@ -169,17 +169,18 @@ struct configuration {
}
bool can_vote(server_id id) const {
bool can_vote = false;
auto it = current.find(server_address{.id=id});
if (it != current.end()) {
return it->can_vote;
can_vote |= it->can_vote;
}
it = previous.find(server_address{.id=id});
if (it != previous.end()) {
return it->can_vote;
can_vote |= it->can_vote;
}
return false;
return can_vote;
}
// Enter a joint configuration given a new set of servers.