mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-04 05:58:40 +00:00
node: only delete db ref on close successfully (#35083)
This commit is contained in:
parent
5016e54406
commit
831ef5a453
1 changed files with 7 additions and 4 deletions
11
node/node.go
11
node/node.go
|
|
@ -772,10 +772,13 @@ type closeTrackingDB struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *closeTrackingDB) Close() error {
|
func (db *closeTrackingDB) Close() error {
|
||||||
db.n.lock.Lock()
|
err := db.Database.Close()
|
||||||
delete(db.n.databases, db)
|
if err == nil {
|
||||||
db.n.lock.Unlock()
|
db.n.lock.Lock()
|
||||||
return db.Database.Close()
|
delete(db.n.databases, db)
|
||||||
|
db.n.lock.Unlock()
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapDatabase ensures the database will be auto-closed when Node is closed.
|
// wrapDatabase ensures the database will be auto-closed when Node is closed.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue