Fix race condition when shutting down and watchPeers() run

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
Hector Sanjuan 2018-10-26 14:45:16 +02:00
parent d63a5e2667
commit ca3fe646b1

View File

@ -313,6 +313,8 @@ func (c *Cluster) watchPeers() {
}
if !hasMe {
c.shutdownLock.Lock()
defer c.shutdownLock.Unlock()
logger.Infof("%s: removed from raft. Initiating shutdown", c.id.Pretty())
c.removed = true
go c.Shutdown()