diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-08-12 16:40:56 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-08-12 16:40:59 +0000 |
commit | 5951d9fe3224b11ba9ae45df4fe44804ec0efd83 (patch) | |
tree | bba5af0afb80f525ff377758502120076f8564d2 /src | |
parent | 9b1b1a06a14ec30852c3a51d3d3808ce9fcaabac (diff) | |
parent | 5d53f48acbbba0ac80e8a26545a3ecaf8d139356 (diff) | |
download | bitcoin-5951d9fe3224b11ba9ae45df4fe44804ec0efd83.tar.xz |
Merge branch 'bugfix_CNBerr' into 0.5.x
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoinrpc.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 60852a2729..944f1415cc 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1764,16 +1764,26 @@ Value getmemorypool(const Array& params, bool fHelp) if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { + // Clear pindexPrev so future calls make a new block, despite any failures from here on + pindexPrev = NULL; + + // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; - pindexPrev = pindexBest; + CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block if(pblock) + { delete pblock; + pblock = NULL; + } pblock = CreateNewBlock(reservekey); if (!pblock) throw JSONRPCError(-7, "Out of memory"); + + // Need to update only after we know CreateNewBlock succeeded + pindexPrev = pindexPrevNew; } // Update nTime |