Skip to content

Commit

Permalink
Fixing race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
rwrz committed Dec 29, 2022
1 parent 5f246de commit 68aad8b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (n *Node) runAsFollower() {
// Process a LEADER's heartbeat.
case hb := <-n.HeartBeats:
// Set the Leader regardless if we currently have none set.
if n.leader == NO_LEADER {
if n.Leader() == NO_LEADER {
n.setLeader(hb.Leader)
}
// Just set Leader if asked to stepdown.
Expand Down Expand Up @@ -494,9 +494,9 @@ func (n *Node) handleVoteRequest(vreq *pb.VoteRequest) bool {

// Newer term
if vreq.Term > n.term {
n.term = vreq.Term
n.vote = NO_VOTE
n.leader = NO_LEADER
n.setTerm(vreq.Term)
n.setVote(NO_VOTE)
n.setLeader(NO_LEADER)
stepDown = true
}

Expand Down

0 comments on commit 68aad8b

Please sign in to comment.