| 260 | } |
| 261 | |
| 262 | void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet) |
| 263 | { |
| 264 | // Mark wallet for unloading. |
| 265 | const std::string name = wallet->GetName(); |
| 266 | { |
| 267 | LOCK(g_wallet_release_mutex); |
| 268 | g_unloading_wallet_set.insert(name); |
| 269 | // Do not expect to be the only one removing this wallet. |
| 270 | // Multiple threads could simultaneously be waiting for deletion. |
| 271 | } |
| 272 | |
| 273 | // Time to ditch our shared_ptr and wait for FlushAndDeleteWallet call. |
| 274 | wallet.reset(); |
| 275 | { |
| 276 | WAIT_LOCK(g_wallet_release_mutex, lock); |
| 277 | while (g_unloading_wallet_set.contains(name)) { |
| 278 | g_wallet_release_cv.wait(lock); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | namespace { |
| 284 | std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings) |