Skip to content

Commit

Permalink
[FAB-2944]: Make leadership callback synchronous
Browse files Browse the repository at this point in the history
In order to make leader election test consistent and not to fail this
commit makes switching leadership state synchronous.

Change-Id: Ie04155bd089f0e7e8553bca9df33e14e0d332817
Signed-off-by: Artem Barger <[email protected]>
  • Loading branch information
C0rWin committed Apr 1, 2017
1 parent 4e5f45c commit d829851
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gossip/election/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ func (le *leaderElectionSvcImpl) IsLeader() bool {
func (le *leaderElectionSvcImpl) beLeader() {
le.logger.Debug(le.id, ": Becoming a leader")
atomic.StoreInt32(&le.isLeader, int32(1))
go le.callback(true)
le.callback(true)
}

func (le *leaderElectionSvcImpl) stopBeingLeader() {
le.logger.Debug(le.id, "Stopped being a leader")
atomic.StoreInt32(&le.isLeader, int32(0))
go le.callback(false)
le.callback(false)
}

func (le *leaderElectionSvcImpl) shouldStop() bool {
Expand Down

0 comments on commit d829851

Please sign in to comment.