From da12747636e2bd6d71e40df2fd60eff050f720e6 Mon Sep 17 00:00:00 2001 From: BurtonQin Date: Wed, 12 Feb 2020 18:42:43 +0800 Subject: [PATCH] event, p2p/simulations/adapters: use buffered channel to avoid goroutine leak --- event/subscription.go | 2 +- p2p/simulations/adapters/exec.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/event/subscription.go b/event/subscription.go index d03f465075..26efbf994b 100644 --- a/event/subscription.go +++ b/event/subscription.go @@ -143,7 +143,7 @@ func (s *resubscribeSub) loop() { } func (s *resubscribeSub) subscribe() Subscription { - subscribed := make(chan error) + subscribed := make(chan error, 1) var sub Subscription retry: for { diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index 7c6ec94621..18ec9c69b8 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -287,7 +287,7 @@ func (n *ExecNode) Stop() error { if err := n.Cmd.Process.Signal(syscall.SIGTERM); err != nil { return n.Cmd.Process.Kill() } - waitErr := make(chan error) + waitErr := make(chan error, 1) go func() { waitErr <- n.Cmd.Wait() }()