@ -556,6 +556,7 @@ void BerkeleyBatch::Close()
LOCK ( cs_db ) ;
- - env - > mapFileUseCount [ strFile ] ;
}
env - > m_db_in_use . notify_all ( ) ;
}
void BerkeleyEnvironment : : CloseDb ( const std : : string & strFile )
@ -572,6 +573,32 @@ void BerkeleyEnvironment::CloseDb(const std::string& strFile)
}
}
void BerkeleyEnvironment : : ReloadDbEnv ( )
{
// Make sure that no Db's are in use
AssertLockNotHeld ( cs_db ) ;
std : : unique_lock < CCriticalSection > lock ( cs_db ) ;
m_db_in_use . wait ( lock , [ this ] ( ) {
for ( auto & count : mapFileUseCount ) {
if ( count . second > 0 ) return false ;
}
return true ;
} ) ;
std : : vector < std : : string > filenames ;
for ( auto it : mapDb ) {
filenames . push_back ( it . first ) ;
}
// Close the individual Db's
for ( const std : : string & filename : filenames ) {
CloseDb ( filename ) ;
}
// Reset the environment
Flush ( true ) ; // This will flush and close the environment
Reset ( ) ;
Open ( true ) ;
}
bool BerkeleyBatch : : Rewrite ( BerkeleyDatabase & database , const char * pszSkip )
{
if ( database . IsDummy ( ) ) {
@ -802,3 +829,10 @@ void BerkeleyDatabase::Flush(bool shutdown)
}
}
}
void BerkeleyDatabase : : ReloadDbEnv ( )
{
if ( ! IsDummy ( ) ) {
env - > ReloadDbEnv ( ) ;
}
}