From 716c685f10c6cfdb84abc74900773c7be2b96f4c Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 21 Nov 2022 01:18:23 +0800 Subject: [PATCH] discovery+peer: add logs to reveal shutdown flow Also adds a `TODO` for checking the err chan. --- discovery/gossiper.go | 1 + discovery/reliable_sender.go | 3 +++ discovery/sync_manager.go | 3 +++ discovery/syncer.go | 3 +++ peer/brontide.go | 2 ++ 5 files changed, 12 insertions(+) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 77d23bde1..c4dd5185e 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -658,6 +658,7 @@ func (d *AuthenticatedGossiper) Stop() error { func (d *AuthenticatedGossiper) stop() { log.Info("Authenticated Gossiper is stopping") + defer log.Info("Authenticated Gossiper stopped") d.blockEpochs.Cancel() diff --git a/discovery/reliable_sender.go b/discovery/reliable_sender.go index b22a15ae1..b4d32e73f 100644 --- a/discovery/reliable_sender.go +++ b/discovery/reliable_sender.go @@ -84,6 +84,9 @@ func (s *reliableSender) Start() error { // Stop halts the reliable sender from sending messages to peers. func (s *reliableSender) Stop() { s.stop.Do(func() { + log.Debugf("reliableSender is stopping") + defer log.Debugf("reliableSender stopped") + close(s.quit) s.wg.Wait() }) diff --git a/discovery/sync_manager.go b/discovery/sync_manager.go index d834be6b2..8123c37eb 100644 --- a/discovery/sync_manager.go +++ b/discovery/sync_manager.go @@ -183,6 +183,9 @@ func (m *SyncManager) Start() { // Stop stops the SyncManager from performing its duties. func (m *SyncManager) Stop() { m.stop.Do(func() { + log.Debugf("SyncManager is stopping") + defer log.Debugf("SyncManager stopped") + close(m.quit) m.wg.Wait() diff --git a/discovery/syncer.go b/discovery/syncer.go index 11424a61e..f5c1bace5 100644 --- a/discovery/syncer.go +++ b/discovery/syncer.go @@ -450,6 +450,9 @@ func (g *GossipSyncer) Start() { // exited. func (g *GossipSyncer) Stop() { g.stopped.Do(func() { + log.Debugf("Stopping GossipSyncer(%x)", g.cfg.peerPub[:]) + defer log.Debugf("GossipSyncer(%x) stopped", g.cfg.peerPub[:]) + close(g.quit) g.wg.Wait() }) diff --git a/peer/brontide.go b/peer/brontide.go index 018f81245..7ac65aaf8 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -1401,6 +1401,8 @@ func newChanMsgStream(p *Brontide, cid lnwire.ChannelID) *msgStream { // channel announcements. func newDiscMsgStream(p *Brontide) *msgStream { apply := func(msg lnwire.Message) { + // TODO(yy): `ProcessRemoteAnnouncement` returns an error chan + // and we need to process it. p.cfg.AuthGossiper.ProcessRemoteAnnouncement(msg, p) }