From e13d451e5429b514b84afa748faf3c254aff9735 Mon Sep 17 00:00:00 2001 From: welkin22 <136572398+welkin22@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:28:05 +0800 Subject: [PATCH] fix: refraining from using gopool for long-running tasks (#20) Co-authored-by: Welkin --- eth/bloombits.go | 5 ++--- p2p/dial.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/eth/bloombits.go b/eth/bloombits.go index 314317ae4f..0cb7050d23 100644 --- a/eth/bloombits.go +++ b/eth/bloombits.go @@ -20,7 +20,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common/bitutil" - "github.com/ethereum/go-ethereum/common/gopool" "github.com/ethereum/go-ethereum/core/rawdb" ) @@ -46,7 +45,7 @@ const ( // retrievals from possibly a range of filters and serving the data to satisfy. func (eth *Ethereum) startBloomHandlers(sectionSize uint64) { for i := 0; i < bloomServiceThreads; i++ { - gopool.Submit(func() { + go func() { for { select { case <-eth.closeBloomHandler: @@ -70,6 +69,6 @@ func (eth *Ethereum) startBloomHandlers(sectionSize uint64) { request <- task } } - }) + }() } } diff --git a/p2p/dial.go b/p2p/dial.go index 49bf6d543a..c5dc3c41fa 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -178,8 +178,8 @@ func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupF d.lastStatsLog = d.clock.Now() d.ctx, d.cancel = context.WithCancel(context.Background()) d.wg.Add(2) - gopool.Submit(func() { d.readNodes(it) }) - gopool.Submit(func() { d.loop(it) }) + go func() { d.readNodes(it) }() + go func() { d.loop(it) }() return d }