Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet: avoid locking
cs_wallet
throughout Create
's entire scope
Implement portions of f13a22a (bitcoin#22868) to sidestep inconsistent lock order by further scoping `cs_wallet` and exiting that scope before locking `cs_wallet_manager_map` ``` POTENTIAL DEADLOCK DETECTED Previous lock order was: (2) 'walletInstance->cs_wallet' in wallet/wallet.cpp:4932 (in thread 'init') (1) 'm_walletman.cs_wallet_manager_map' in coinjoin/interfaces.cpp:72 (in thread 'init') Current lock order is: (1) 'm_walletman.cs_wallet_manager_map' in coinjoin/interfaces.cpp:72 (in thread 'init') (2) 'cs_wallet' in wallet/wallet.cpp:5530 (in thread 'init') ``` Additionally, don't bother to see if the wallet is locked when doing a re-init of CoinJoin, just stop mixing (it'll restart anyway if `-coinjoinautostart` is set) because we're working from wallet code and it's very likely that calls to the CoinJoin interface will already hold a `cs_wallet`. Which is a problem because re-init'ing involves going through every wallet and stopping the mix process. If we check to see if the wallet is locked first, it involves locking `cs_wallet` briefly. If we're already holding `cs_wallet`, the order is `cs_wallet` and then `cs_wallet_manager_map` but if we *don't* hold any `cs_wallet`, then the order will reverse because we still need to lock `cs_wallet` to see if it's locked, which spells trouble for us.
- Loading branch information