Fix potential deadlock in LoadWallet() (#2806)

* Fix potential deadlock in LoadWallet()

```
POTENTIAL DEADLOCK DETECTED
Previous lock order was:
 (1) cs_main  wallet/wallet.cpp:3881
 (2) cs_wallet  wallet/wallet.cpp:3881
Current lock order is:
 (2) pwallet->cs_wallet  wallet/walletdb.cpp:589
 (1) cs_main  wallet/wallet.cpp:1252
```

* Add comment in CWallet::MarkConflicted re new cs_main lock in CWalletDB::LoadWallet()
This commit is contained in:
UdjinM6 2019-03-25 18:33:07 +03:00 committed by GitHub
parent 81eeff1c54
commit 162acc5a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -1249,7 +1249,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
{
LOCK2(cs_main, cs_wallet);
LOCK2(cs_main, cs_wallet); // check "LOCK2(cs_main, pwallet->cs_wallet);" in CWalletDB::LoadWallet()
int conflictconfirms = 0;
if (mapBlockIndex.count(hashBlock)) {

View File

@ -586,7 +586,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
bool fNoncriticalErrors = false;
DBErrors result = DB_LOAD_OK;
LOCK(pwallet->cs_wallet);
LOCK2(cs_main, pwallet->cs_wallet);
try {
int nMinVersion = 0;
if (Read((std::string)"minversion", nMinVersion))