mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
Fixes a data race on the `wallets` slice when closing account Manager. At the moment, there is a data race between a go-routine calling the Manager's `Close` function and the background go-routine handling most operations on the `Manager`. The `Manager`'s `wallets` field is accessed without proper synchronization. By moving the closing of wallets from the `Close()` function into the background thread, this issue can be resolved. Co-authored-by: Herbert <herbert.jordan.jun@gmail.com>
This commit is contained in:
parent
b6f28effa9
commit
aec5f28dab
1 changed files with 4 additions and 3 deletions
|
|
@ -98,9 +98,6 @@ func NewManager(config *Config, backends ...Backend) *Manager {
|
||||||
|
|
||||||
// Close terminates the account manager's internal notification processes.
|
// Close terminates the account manager's internal notification processes.
|
||||||
func (am *Manager) Close() error {
|
func (am *Manager) Close() error {
|
||||||
for _, w := range am.wallets {
|
|
||||||
w.Close()
|
|
||||||
}
|
|
||||||
errc := make(chan error)
|
errc := make(chan error)
|
||||||
am.quit <- errc
|
am.quit <- errc
|
||||||
return <-errc
|
return <-errc
|
||||||
|
|
@ -159,6 +156,10 @@ func (am *Manager) update() {
|
||||||
am.lock.Unlock()
|
am.lock.Unlock()
|
||||||
close(event.processed)
|
close(event.processed)
|
||||||
case errc := <-am.quit:
|
case errc := <-am.quit:
|
||||||
|
// Close all owned wallets
|
||||||
|
for _, w := range am.wallets {
|
||||||
|
w.Close()
|
||||||
|
}
|
||||||
// Manager terminating, return
|
// Manager terminating, return
|
||||||
errc <- nil
|
errc <- nil
|
||||||
// Signals event emitters the loop is not receiving values
|
// Signals event emitters the loop is not receiving values
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue