rpc: Make unloadwallet wait for complete wallet unload

This commit is contained in:
João Barbosa
2018-12-12 23:21:19 +00:00
parent e7b88ecbc9
commit c37851de57
5 changed files with 56 additions and 12 deletions
+1 -9
View File
@@ -2625,16 +2625,8 @@ static UniValue unloadwallet(const JSONRPCRequest& request)
if (!RemoveWallet(wallet)) {
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
}
UnregisterValidationInterface(wallet.get());
// The wallet can be in use so it's not possible to explicitly unload here.
// Just notify the unload intent so that all shared pointers are released.
// The wallet will be destroyed once the last shared pointer is released.
wallet->NotifyUnload();
// There's no point in waiting for the wallet to unload.
// At this point this method should never fail. The unloading could only
// fail due to an unexpected error which would cause a process termination.
UnloadWallet(std::move(wallet));
return NullUniValue;
}