Fix a potencial race in CWallet::ListCoins.
Replaces cs_main and cs_wallet locks by assertions in CWallet::AvailableCoins.
Fix a potencial race in CWallet::ListCoins.
Replaces cs_main and cs_wallet locks by assertions in CWallet::AvailableCoins.
2197@@ -2198,111 +2198,109 @@ CAmount CWallet::GetAvailableBalance(const CCoinControl* coinControl) const
2198
2199 void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const CCoinControl *coinControl, const CAmount &nMinimumAmount, const CAmount &nMaximumAmount, const CAmount &nMinimumSumAmount, const uint64_t nMaximumCount, const int nMinDepth, const int nMaxDepth) const
2200 {
2201+ AssertLockHeld(cs_main);
2202+ AssertLockHeld(cs_wallet);
LOCK2 here?
I think in general we want to move away from recursive locking: https://github.com/bitcoin/bitcoin/blob/85123be78df5a4e9447e70f9ee727416d45843d7/src/sync.h#L92
http://www.zaval.org/resources/library/butenhof1.html has some interesting rationale and history
-w / ?w=1).
676@@ -677,11 +677,11 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
677
678 // Lock both coins. Confirm number of available coins drops to 0.
679 std::vector<COutput> available;
680+ LOCK2(cs_main, wallet->cs_wallet);
ListCoins below if you prefer.