From f5f1878ba104a5d6a32eeb20b341326dca6086a5 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 4 Apr 2011 22:24:35 -0400 Subject: Fix deadlocks in setaccount, sendfrom RPC calls SendMoney*() now requires caller to acquire cs_main. GetAccountAddress() now requires caller to acquire cs_main, cs_mapWallet. Ordering is intended to match these two callchains[1]: 1. CRITICAL_BLOCK(cs_main) ProcessMessage(pfrom, strCommand, vMsg) AddToWalletIfMine() AddToWallet(wtx) CRITICAL_BLOCK(cs_mapWallet) 2. CRITICAL_BLOCK(cs_main) ProcessMessage(pfrom, strCommand, vMsg) AddToWalletIfMine() AddToWallet(wtx) CRITICAL_BLOCK(cs_mapWallet) walletdb.WriteName(PubKeyToAddress(vchDefaultKey), "") CRITICAL_BLOCK(cs_mapAddressBook) Spotted by ArtForz. Additional deadlock fixes by Gavin. [1] http://www.bitcoin.org/smf/index.php?topic=4904.msg71897#msg71897 --- db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db.cpp') diff --git a/db.cpp b/db.cpp index aaa997be2..3cfcce569 100644 --- a/db.cpp +++ b/db.cpp @@ -668,8 +668,8 @@ bool CWalletDB::LoadWallet() #endif //// todo: shouldn't we catch exceptions and try to recover and continue? - CRITICAL_BLOCK(cs_mapKeys) CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_mapKeys) { // Get cursor Dbc* pcursor = GetCursor(); -- cgit v1.2.3