From 6d6183762c18be4bdef5e7569d10aaa000b7da0a Mon Sep 17 00:00:00 2001 From: steven Date: Wed, 29 May 2024 09:17:46 +0800 Subject: [PATCH] rename wg to startupWG --- accounts/keystore/account_cache.go | 2 +- accounts/keystore/watch.go | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go index f20f0f8af5..b5cc75c48d 100644 --- a/accounts/keystore/account_cache.go +++ b/accounts/keystore/account_cache.go @@ -220,7 +220,7 @@ func (ac *accountCache) maybeReload() { ac.watcher.start() ac.throttle.Reset(minReloadInterval) ac.mu.Unlock() - ac.watcher.wg.Wait() + ac.watcher.startupWG.Wait() ac.scanAccounts() } diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go index b4994082cb..cededf1941 100644 --- a/accounts/keystore/watch.go +++ b/accounts/keystore/watch.go @@ -29,19 +29,19 @@ import ( ) type watcher struct { - ac *accountCache - running bool // set to true when runloop begins - runEnded bool // set to true when runloop ends - starting bool // set to true prior to runloop starting - quit chan struct{} - wg sync.WaitGroup // wait for watcher loop to start + ac *accountCache + running bool // set to true when runloop begins + 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{}), - wg: sync.WaitGroup{}, + ac: ac, + quit: make(chan struct{}), + startupWG: sync.WaitGroup{}, } } @@ -55,7 +55,7 @@ func (w *watcher) start() { if w.starting || w.running { return } - w.wg.Add(1) + w.startupWG.Add(1) w.starting = true go w.loop() } @@ -81,12 +81,11 @@ func (w *watcher) loop() { return } defer watcher.Close() - if err := watcher.Add(w.ac.keydir); err != nil { if !os.IsNotExist(err) { logger.Warn("Failed to watch keystore folder", "err", err) } - w.wg.Done() + w.startupWG.Done() return } @@ -110,7 +109,7 @@ func (w *watcher) loop() { <-debounce.C } defer debounce.Stop() - w.wg.Done() + w.startupWG.Done() for { select { case <-w.quit: