Skip to content

Commit a769461

Browse files
committed
Move BerkeleyEnvironment deletion from internal method to callsite
Instead of having the object destroy itself, having the caller destroy it.
1 parent f66e1c7 commit a769461

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wallet/db.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
697697
if (!fMockDb) {
698698
fs::remove_all(fs::path(strPath) / "database");
699699
}
700-
g_dbenvs.erase(strPath);
701700
}
702701
}
703702
}
@@ -796,6 +795,10 @@ void BerkeleyDatabase::Flush(bool shutdown)
796795
{
797796
if (!IsDummy()) {
798797
env->Flush(shutdown);
799-
if (shutdown) env = nullptr;
798+
if (shutdown) {
799+
LOCK(cs_db);
800+
g_dbenvs.erase(env->Directory().string());
801+
env = nullptr;
802+
}
800803
}
801804
}

0 commit comments

Comments
 (0)