From 6c458f32f80db882df02a1766f5d4cdbd930bcb7 Mon Sep 17 00:00:00 2001 From: ucwong Date: Tue, 21 Apr 2020 22:42:18 +0800 Subject: [PATCH] p2p: defer wait group done in protocol start (#20951) --- p2p/peer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/peer.go b/p2p/peer.go index 4398ad0f2..52a777cd1 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -365,6 +365,7 @@ func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) } p.log.Trace(fmt.Sprintf("Starting protocol %s/%d", proto.Name, proto.Version)) go func() { + defer p.wg.Done() err := proto.Run(p, rw) if err == nil { p.log.Trace(fmt.Sprintf("Protocol %s/%d returned", proto.Name, proto.Version)) @@ -373,7 +374,6 @@ func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) p.log.Trace(fmt.Sprintf("Protocol %s/%d failed", proto.Name, proto.Version), "err", err) } p.protoErr <- err - p.wg.Done() }() } }