From e7a41fab8f4d0a38ce00e6dd2c94dcbca8f7019b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 2 Apr 2013 16:46:28 -0700 Subject: [PATCH 1/4] Restore the original behavior. We do not want to call RAND_screen because it calls RAND_poll. Let me know if this breaks anything. --- src/cpp/ripple/PlatRand.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cpp/ripple/PlatRand.cpp b/src/cpp/ripple/PlatRand.cpp index 6db6203116..e367cbf841 100644 --- a/src/cpp/ripple/PlatRand.cpp +++ b/src/cpp/ripple/PlatRand.cpp @@ -8,12 +8,9 @@ bool AddSystemEntropy() { // Get entropy from the Windows crypto provider - RAND_screen(); // this isn't really that safe since it only works for end users not servers - -/* TODO: you need the cryptoAPI installed I think for the below to work. I suppose we should require people to install this to build the windows version char name[512], rand[128]; DWORD count = 500; - HCRYPTOPROV cryptoHandle; + HCRYPTPROV cryptoHandle; if (!CryptGetDefaultProvider(PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, name, &count)) { @@ -43,7 +40,6 @@ bool AddSystemEntropy() CryptReleaseContext(cryptoHandle, 0); RAND_seed(rand, 128); -*/ return true; } From 1894b2d4b83b525448c377f07c4a42f8a1f11546 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 3 Apr 2013 13:47:09 -0700 Subject: [PATCH 2/4] Missing log message. --- src/cpp/ripple/UpdateTables.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpp/ripple/UpdateTables.cpp b/src/cpp/ripple/UpdateTables.cpp index 6d829d9495..240c8fd1f7 100644 --- a/src/cpp/ripple/UpdateTables.cpp +++ b/src/cpp/ripple/UpdateTables.cpp @@ -96,6 +96,7 @@ static void addTxnSeqField() Log(lsINFO) << i << " transactions updated"; } + Log(lsINFO) << "Building new index"; db->executeSQL("CREATE INDEX AcctTxIndex ON AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);"); db->executeSQL("END TRANSACTION;"); } From 88dba87fa983ba0ab1305defff5d7517eadb0667 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 3 Apr 2013 14:17:06 -0700 Subject: [PATCH 3/4] Fix the deadlock. Can't hold the LedgerMaster lock when calling a pub* function. --- src/cpp/ripple/LedgerMaster.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index a9471493a7..25184f1c40 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -122,10 +122,13 @@ Ledger::pointer LedgerMaster::closeLedger(bool recover) TER LedgerMaster::doTransaction(SerializedTransaction::ref txn, TransactionEngineParams params, bool& didApply) { - boost::recursive_mutex::scoped_lock sl(mLock); - TER result = mEngine.applyTransaction(*txn, params, didApply); + { + boost::recursive_mutex::scoped_lock sl(mLock); + TER result = mEngine.applyTransaction(*txn, params, didApply); + Ledger::pointer ledger = mEngine.getLedger(); + } // if (didApply) - theApp->getOPs().pubProposedTransaction(mEngine.getLedger(), txn, result); + theApp->getOPs().pubProposedTransaction(ledger, txn, result); return result; } From 5d4e7db788d81a6616381b4edc643bf830efbf38 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 3 Apr 2013 14:20:20 -0700 Subject: [PATCH 4/4] Fix the fix. --- src/cpp/ripple/LedgerMaster.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index 25184f1c40..20a3d93c06 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -122,10 +122,13 @@ Ledger::pointer LedgerMaster::closeLedger(bool recover) TER LedgerMaster::doTransaction(SerializedTransaction::ref txn, TransactionEngineParams params, bool& didApply) { + Ledger::pointer ledger; + TER result; + { boost::recursive_mutex::scoped_lock sl(mLock); - TER result = mEngine.applyTransaction(*txn, params, didApply); - Ledger::pointer ledger = mEngine.getLedger(); + result = mEngine.applyTransaction(*txn, params, didApply); + ledger = mEngine.getLedger(); } // if (didApply) theApp->getOPs().pubProposedTransaction(ledger, txn, result);