Skip to content

Commit

Permalink
Wait for comm layer to stop when gossip stops
Browse files Browse the repository at this point in the history
Gossip's Stop() method stops underlying comm layer
asynchronously but doesn't wait for it to stop.
I simply changed it so that it now waits for it to stop
until the Stop() method exits.

Change-Id: I200a3d39408252e07c2b1fe6535515c3aea1e078
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Nov 24, 2016
1 parent ebd9943 commit b7e65d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gossip/gossip/gossip_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,20 @@ func (g *gossipServiceImpl) Stop() {
}
atomic.StoreInt32((&g.stopFlag), int32(1))
g.logger.Info("Stopping gossip")
go g.comm.Stop()
comWG := sync.WaitGroup{}
comWG.Add(1)
go func() {
defer comWG.Done()
g.comm.Stop()
}()
g.discAdapter.close()
go g.disc.Stop()
go g.pushPull.Stop()
g.disc.Stop()
g.pushPull.Stop()
g.toDieChan <- struct{}{}
g.emitter.Stop()
g.ChannelDeMultiplexer.Close()
g.stopSignal.Wait()
comWG.Wait()
}

func (g *gossipServiceImpl) UpdateMetadata(md []byte) {
Expand Down

0 comments on commit b7e65d8

Please sign in to comment.