mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
remove waitgroup and apply a straightforward fix
This commit is contained in:
parent
6d6183762c
commit
d255b54cf6
3 changed files with 13 additions and 17 deletions
|
|
@ -220,7 +220,6 @@ func (ac *accountCache) maybeReload() {
|
|||
ac.watcher.start()
|
||||
ac.throttle.Reset(minReloadInterval)
|
||||
ac.mu.Unlock()
|
||||
ac.watcher.startupWG.Wait()
|
||||
ac.scanAccounts()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -326,6 +326,11 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||
|
||||
// Create a temporary keystore to test with
|
||||
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int()))
|
||||
|
||||
// Create the directory
|
||||
os.MkdirAll(dir, 0700)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
||||
|
||||
list := ks.Accounts()
|
||||
|
|
@ -335,9 +340,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||
if !waitWatcherStart(ks) {
|
||||
t.Fatal("keystore watcher didn't start in time")
|
||||
}
|
||||
// Create the directory and copy a key file into it.
|
||||
os.MkdirAll(dir, 0700)
|
||||
defer os.RemoveAll(dir)
|
||||
// Copy a key file into it
|
||||
file := filepath.Join(dir, "aaa")
|
||||
|
||||
// Place one of our testfiles in there
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package keystore
|
|||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
|
@ -34,14 +33,12 @@ type watcher struct {
|
|||
runEnded bool // set to true when runloop ends
|
||||
starting bool // set to true prior to runloop starting
|
||||
quit chan struct{}
|
||||
startupWG sync.WaitGroup // wait for watcher loop to start
|
||||
}
|
||||
|
||||
func newWatcher(ac *accountCache) *watcher {
|
||||
return &watcher{
|
||||
ac: ac,
|
||||
quit: make(chan struct{}),
|
||||
startupWG: sync.WaitGroup{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +52,6 @@ func (w *watcher) start() {
|
|||
if w.starting || w.running {
|
||||
return
|
||||
}
|
||||
w.startupWG.Add(1)
|
||||
w.starting = true
|
||||
go w.loop()
|
||||
}
|
||||
|
|
@ -85,7 +81,6 @@ func (w *watcher) loop() {
|
|||
if !os.IsNotExist(err) {
|
||||
logger.Warn("Failed to watch keystore folder", "err", err)
|
||||
}
|
||||
w.startupWG.Done()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +104,6 @@ func (w *watcher) loop() {
|
|||
<-debounce.C
|
||||
}
|
||||
defer debounce.Stop()
|
||||
w.startupWG.Done()
|
||||
for {
|
||||
select {
|
||||
case <-w.quit:
|
||||
|
|
|
|||
Loading…
Reference in a new issue