Skip to content

Commit ed8ad3d

Browse files
committed
brontide: remove async goroutine to process gossip process result
We cannot rely on a response currently so we avoid spawning goroutines. This is just a temporary fix to avoid the goroutine leak.
1 parent dedb75a commit ed8ad3d

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

peer/brontide.go

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,32 +1990,22 @@ func newDiscMsgStream(p *Brontide) *msgStream {
19901990
// so that a parent context can be passed in here.
19911991
ctx := context.TODO()
19921992

1993+
// Processing here means we send it to the gossiper which then
1994+
// decides whether this message is processed immediately or
1995+
// waits for dependent messages to be processed. It can also
1996+
// happen that the message is not processed at all if it is
1997+
// premature and the LRU cache fills up and the message is
1998+
// deleted.
19931999
p.log.Debugf("Processing remote msg %T", msg)
19942000

1995-
errChan := p.cfg.AuthGossiper.ProcessRemoteAnnouncement(
1996-
ctx, msg, p,
1997-
)
1998-
1999-
// Start a goroutine to process the error channel for logging
2000-
// purposes.
2001-
//
2002-
// TODO(ziggie): Maybe use the error to potentially punish the
2003-
// peer depending on the error ?
2004-
go func() {
2005-
select {
2006-
case <-p.cg.Done():
2007-
return
2008-
2009-
case err := <-errChan:
2010-
if err != nil {
2011-
p.log.Warnf("Error processing remote "+
2012-
"msg %T: %v", msg,
2013-
err)
2014-
}
2015-
}
2016-
2017-
p.log.Debugf("Processed remote msg %T", msg)
2018-
}()
2001+
// TODO(ziggie): ProcessRemoteAnnouncement returns an error
2002+
// channel, but we cannot rely on it being written to.
2003+
// Because some messages might never be processed (e.g.
2004+
// premature channel updates). We should change the design here
2005+
// and use the actor model pattern as soon as it is available.
2006+
// So for now we should NOT use the error channel.
2007+
// See https://github.com/lightningnetwork/lnd/pull/9820.
2008+
p.cfg.AuthGossiper.ProcessRemoteAnnouncement(ctx, msg, p)
20192009
}
20202010

20212011
return newMsgStream(

0 commit comments

Comments
 (0)