close old db when rewriting

This commit is contained in:
Pieter Wuille 2011-11-20 17:12:00 +01:00 committed by Gavin Andresen
parent b2d3b2d65d
commit f53c5ede73
1 changed files with 55 additions and 53 deletions

View File

@ -195,6 +195,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
bool fSuccess = true;
printf("Rewriting %s...\n", strFile.c_str());
string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {}
CDB db(strFile.c_str(), "r");
Db* pdbCopy = new Db(&dbenv, 0);
@ -251,6 +252,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
fSuccess = false;
delete pdbCopy;
}
}
if (fSuccess)
{
Db dbA(&dbenv, 0);