mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
use time.After instead of sleep, incase of goroutine leak
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
116f327c27
commit
c3204b338d
1 changed files with 9 additions and 8 deletions
|
|
@ -155,18 +155,19 @@ func (g *StateSizeGenerator) initialize() chan struct{} {
|
|||
LOOP:
|
||||
// Wait for snapshot generator to complete first
|
||||
for {
|
||||
select {
|
||||
case <-g.abort:
|
||||
log.Info("State size initialization aborted during snapshot wait")
|
||||
return
|
||||
default:
|
||||
root, done := g.triedb.SnapshotCompleted()
|
||||
if done {
|
||||
g.metrics.Root = root
|
||||
g.buffered.Root = root
|
||||
break LOOP
|
||||
}
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
select {
|
||||
case <-g.abort:
|
||||
log.Info("State size initialization aborted during snapshot wait")
|
||||
return
|
||||
case <-time.After(10 * time.Second):
|
||||
// Continue checking for snapshot completion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue