Skip to content

Commit 0b82bac

Browse files
committed
bugfix: Remove dangling wallet env instance
1 parent 0ee77b2 commit 0b82bac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/wallet/db.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,10 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
694694
if (mapFileUseCount.empty()) {
695695
dbenv->log_archive(&listp, DB_ARCH_REMOVE);
696696
Close();
697-
if (!fMockDb)
697+
if (!fMockDb) {
698698
fs::remove_all(fs::path(strPath) / "database");
699+
}
700+
g_dbenvs.erase(strPath);
699701
}
700702
}
701703
}
@@ -794,5 +796,6 @@ void BerkeleyDatabase::Flush(bool shutdown)
794796
{
795797
if (!IsDummy()) {
796798
env->Flush(shutdown);
799+
if (shutdown) env = nullptr;
797800
}
798801
}

test/functional/wallet_multiwallet.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,10 @@ def run_test(self):
256256
assert_equal(self.nodes[0].listwallets(), [])
257257
assert_raises_rpc_error(-32601, "Method not found (wallet method is disabled because no wallet is loaded)", self.nodes[0].getwalletinfo)
258258

259+
# Successfully load a previously unloaded wallet
260+
self.nodes[0].loadwallet('w1')
261+
assert_equal(self.nodes[0].listwallets(), ['w1'])
262+
assert_equal(w1.getwalletinfo()['walletname'], 'w1')
263+
259264
if __name__ == '__main__':
260265
MultiWalletTest().main()

0 commit comments

Comments
 (0)