mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
mdbx: proper atomic close (#827)
This commit is contained in:
parent
d2d03d140b
commit
493ae8b083
@ -431,10 +431,9 @@ func (db *MdbxKV) openDBIs(buckets []string) error {
|
|||||||
// Close closes db
|
// Close closes db
|
||||||
// All transactions must be closed before closing the database.
|
// All transactions must be closed before closing the database.
|
||||||
func (db *MdbxKV) Close() {
|
func (db *MdbxKV) Close() {
|
||||||
if db.closed.Load() {
|
if db.closed.CompareAndSwap(false, true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db.closed.Store(true)
|
|
||||||
db.wg.Wait()
|
db.wg.Wait()
|
||||||
db.env.Close()
|
db.env.Close()
|
||||||
db.env = nil
|
db.env = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user