aboutsummaryrefslogtreecommitdiff
path: root/ui.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-04-04 22:24:35 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-04-04 22:24:35 -0400
commitf5f1878ba104a5d6a32eeb20b341326dca6086a5 (patch)
tree39284fb8f9a1e82e7f66c49de833c2373dc54b8e /ui.cpp
parent454bc86479a387893604cd662aae994d37699672 (diff)
downloadbitcoin-f5f1878ba104a5d6a32eeb20b341326dca6086a5.tar.xz
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
Diffstat (limited to 'ui.cpp')
-rw-r--r--ui.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/ui.cpp b/ui.cpp
index fafd3893c8..f4c0c4d749 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -1934,20 +1934,23 @@ void CSendDialog::OnButtonSend(wxCommandEvent& event)
if (fBitcoinAddress)
{
- // Send to bitcoin address
- CScript scriptPubKey;
- scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
-
- string strError = SendMoney(scriptPubKey, nValue, wtx, true);
- if (strError == "")
- wxMessageBox(_("Payment sent "), _("Sending..."));
- else if (strError == "ABORTED")
- return; // leave send dialog open
- else
- {
- wxMessageBox(strError + " ", _("Sending..."));
- EndModal(false);
- }
+ CRITICAL_BLOCK(cs_main)
+ {
+ // Send to bitcoin address
+ CScript scriptPubKey;
+ scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
+
+ string strError = SendMoney(scriptPubKey, nValue, wtx, true);
+ if (strError == "")
+ wxMessageBox(_("Payment sent "), _("Sending..."));
+ else if (strError == "ABORTED")
+ return; // leave send dialog open
+ else
+ {
+ wxMessageBox(strError + " ", _("Sending..."));
+ EndModal(false);
+ }
+ }
}
else
{