Wait for follower and leader loops to finish
This commit is contained in:
parent
1650b17e05
commit
0b1601542d
@ -648,10 +648,6 @@ func (c *cluster) Shutdown() error {
|
||||
c.raft.Shutdown()
|
||||
}
|
||||
|
||||
// TODO: here might some situations, where the manager is still need from the synchronize loop and will run into a panic
|
||||
c.manager = nil
|
||||
c.raft = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -180,6 +180,22 @@ func (c *cluster) monitorLeadership() {
|
||||
c.leaderLock.Unlock()
|
||||
}
|
||||
case <-c.shutdownCh:
|
||||
if weAreFollowerCh != nil {
|
||||
close(weAreFollowerCh)
|
||||
}
|
||||
|
||||
if weAreLeaderCh != nil {
|
||||
close(weAreLeaderCh)
|
||||
}
|
||||
|
||||
if weAreEmergencyLeaderCh != nil {
|
||||
close(weAreEmergencyLeaderCh)
|
||||
}
|
||||
|
||||
leaderLoop.Wait()
|
||||
emergencyLeaderLoop.Wait()
|
||||
followerLoop.Wait()
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user