wallet: WaitForDeleteWallet, do not expect thread safety

Multiple threads could try to delete the wallet at the same time.
This commit is contained in:
Ryan Ofsky 2024-08-13 22:52:01 -03:00 committed by furszy
parent 8872b4a6ca
commit 64e736d79e
No known key found for this signature in database
GPG key ID: 5DD23CCC686AA623

View file

@ -250,8 +250,9 @@ void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet)
const std::string name = wallet->GetName();
{
LOCK(g_wallet_release_mutex);
auto it = g_unloading_wallet_set.insert(name);
assert(it.second);
g_unloading_wallet_set.insert(name);
// Do not expect to be the only one removing this wallet.
// Multiple threads could simultaneously be waiting for deletion.
}
// Time to ditch our shared_ptr and wait for ReleaseWallet call.