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:
|
LOOP:
|
||||||
// Wait for snapshot generator to complete first
|
// Wait for snapshot generator to complete first
|
||||||
for {
|
for {
|
||||||
|
root, done := g.triedb.SnapshotCompleted()
|
||||||
|
if done {
|
||||||
|
g.metrics.Root = root
|
||||||
|
g.buffered.Root = root
|
||||||
|
break LOOP
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-g.abort:
|
case <-g.abort:
|
||||||
log.Info("State size initialization aborted during snapshot wait")
|
log.Info("State size initialization aborted during snapshot wait")
|
||||||
return
|
return
|
||||||
default:
|
case <-time.After(10 * time.Second):
|
||||||
root, done := g.triedb.SnapshotCompleted()
|
// Continue checking for snapshot completion
|
||||||
if done {
|
|
||||||
g.metrics.Root = root
|
|
||||||
g.buffered.Root = root
|
|
||||||
break LOOP
|
|
||||||
}
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue