Skip to content

Commit b7e65d8

Browse files
committed
Wait for comm layer to stop when gossip stops
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 <[email protected]>
1 parent ebd9943 commit b7e65d8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gossip/gossip/gossip_impl.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,20 @@ func (g *gossipServiceImpl) Stop() {
382382
}
383383
atomic.StoreInt32((&g.stopFlag), int32(1))
384384
g.logger.Info("Stopping gossip")
385-
go g.comm.Stop()
385+
comWG := sync.WaitGroup{}
386+
comWG.Add(1)
387+
go func() {
388+
defer comWG.Done()
389+
g.comm.Stop()
390+
}()
386391
g.discAdapter.close()
387-
go g.disc.Stop()
388-
go g.pushPull.Stop()
392+
g.disc.Stop()
393+
g.pushPull.Stop()
389394
g.toDieChan <- struct{}{}
390395
g.emitter.Stop()
391396
g.ChannelDeMultiplexer.Close()
392397
g.stopSignal.Wait()
398+
comWG.Wait()
393399
}
394400

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

0 commit comments

Comments
 (0)