cmd: fix quit channel goroutine leak

This commit is contained in:
ucwong 2020-04-03 08:37:02 +00:00
parent f7b29ec942
commit 1863c2d404
3 changed files with 3 additions and 3 deletions

View file

@ -45,7 +45,7 @@ func newCrawler(input nodeSet, disc *discover.UDPv4, iters ...enode.Iterator) *c
iters: iters, iters: iters,
inputIter: enode.IterNodes(input.nodes()), inputIter: enode.IterNodes(input.nodes()),
ch: make(chan *enode.Node), ch: make(chan *enode.Node),
closed: make(chan struct{}), closed: make(chan struct{}, 1),
} }
c.iters = append(c.iters, c.inputIter) c.iters = append(c.iters, c.inputIter)
// Copy input to output initially. Any nodes that fail validation // Copy input to output initially. Any nodes that fail validation

View file

@ -89,7 +89,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
// Watch for Ctrl-C while the import is running. // Watch for Ctrl-C while the import is running.
// If a signal is received, the import will stop at the next batch. // If a signal is received, the import will stop at the next batch.
interrupt := make(chan os.Signal, 1) interrupt := make(chan os.Signal, 1)
stop := make(chan struct{}) stop := make(chan struct{}, 1)
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(interrupt) defer signal.Stop(interrupt)
defer close(interrupt) defer close(interrupt)

View file

@ -175,7 +175,7 @@ func echo() {
func initialize() { func initialize() {
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*argVerbosity), log.StreamHandler(os.Stderr, log.TerminalFormat(false)))) log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*argVerbosity), log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
done = make(chan struct{}) done = make(chan struct{}, 1)
var peers []*enode.Node var peers []*enode.Node
var err error var err error