mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 14:45:23 +01:00
test: bind the inner lightningNetworkWatcher goroutine to the wait group
This commit fixes a race condition detected by the race condition detector that can be triggered by the lightnignNode exiting while the underlying node is still active. Since the wait group wasn’t tied to this cog routine, when the main process was exiting, it wouldn’t also wait for this grouting to exit, thus triggering a race condition of modifying the channel reference while reading for it. The fix for this is straightforward: we now ensure that the goroutine is factored into the struct level wait group.
This commit is contained in:
parent
4939443512
commit
bfdb2bebe2
@ -351,7 +351,10 @@ func (l *lightningNode) lightningNetworkWatcher() {
|
||||
}
|
||||
|
||||
graphUpdates := make(chan *lnrpc.GraphTopologyUpdate)
|
||||
l.wg.Add(1)
|
||||
go func() {
|
||||
defer l.wg.Done()
|
||||
|
||||
ctxb := context.Background()
|
||||
req := &lnrpc.GraphTopologySubscription{}
|
||||
topologyClient, err := l.SubscribeChannelGraph(ctxb, req)
|
||||
@ -748,7 +751,7 @@ out:
|
||||
}
|
||||
|
||||
// Now that the initial test network has been initialized, launch the
|
||||
// network wather.
|
||||
// network watcher.
|
||||
go n.networkWatcher()
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user