aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-10-21 16:08:20 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-10-21 16:16:55 +0200
commit33dfbf57d34882aef7b83bc5ea9bf561e1f3e7b0 (patch)
treea0e9ff5fa63c507e2dda9c8a54da3e523b7fbe73
parent9acbb4180a383ff123e07887a24b439cef846e89 (diff)
downloadbitcoin-33dfbf57d34882aef7b83bc5ea9bf561e1f3e7b0.tar.xz
rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo`
This fixes an iterator leak resulting in bitcoind: db/version_set.cc:789: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failed." exception on shutdown. Also make sure to flush pcoinsTip before calling GetStats() to make sure we apply them to the current height.
-rw-r--r--src/rpcblockchain.cpp1
-rw-r--r--src/txdb.cpp2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 5beac0512a..b0da1d6a5c 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -319,6 +319,7 @@ Value gettxoutsetinfo(const Array& params, bool fHelp)
Object ret;
CCoinsStats stats;
+ pcoinsTip->Flush();
if (pcoinsTip->GetStats(stats)) {
ret.push_back(Pair("height", (int64_t)stats.nHeight));
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
diff --git a/src/txdb.cpp b/src/txdb.cpp
index cb9f150011..8a73ce961c 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -104,7 +104,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
/* It seems that there are no "const iterators" for LevelDB. Since we
only need read operations on it, use a const-cast to get around
that restriction. */
- leveldb::Iterator *pcursor = const_cast<CLevelDBWrapper*>(&db)->NewIterator();
+ boost::scoped_ptr<leveldb::Iterator> pcursor(const_cast<CLevelDBWrapper*>(&db)->NewIterator());
pcursor->SeekToFirst();
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);