Skip to content

Commit

Permalink
Fix data race around leader handling (#20)
Browse files Browse the repository at this point in the history
Fixes #19.
  • Loading branch information
dcelasun authored and garethlewin committed Feb 23, 2019
1 parent b6682f9 commit 6d05cb3
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions kinsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,7 @@ func (k *Kinsumer) Run() error {
if err != nil {
k.errors <- fmt.Errorf("error deregistering client: %s", err)
}
if k.isLeader {
close(k.leaderLost)
k.leaderLost = nil
k.isLeader = false
}
k.unbecomeLeader()
// Do this outside the k.isLeader check in case k.isLeader was false because
// we lost leadership but haven't had time to shutdown the goroutine yet.
k.leaderWG.Wait()
Expand Down

0 comments on commit 6d05cb3

Please sign in to comment.