Merge #14941: rpc: Make unloadwallet wait for complete wallet unload
645e905c32doc: Add release notes for unloadwallet change to synchronous call (João Barbosa)c37851de57rpc: Make unloadwallet wait for complete wallet unload (João Barbosa) Pull request description: Currently the `unloadwallet` RPC is asynchronous, it only signals the intent to unload the wallet and then returns the response to the client. The actual unload can happen later and the client has no way to be notified of that. This PR makes the `unloadwallet` RPC synchronous, meaning that it blocks until the wallet is fully unloaded. Replaces #14919, fixes #14917. Tree-SHA512: ad88b980e2f3652809a58f904afbfe020299f3aa6a517f495ba943b8d54d4520f6e70074d6749be8f5967065c0f476e0faedcde64c8b4899e5f99c70f0fd6534
This commit is contained in:
@@ -2637,16 +2637,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user