Fix crash on reload metrics due to faulty FlushDirCache logic. I will fix the optimization of flushing just a particular directory when I have time.

This commit is contained in:
Steve Checkoway
2009-11-04 11:19:45 +00:00
parent 006bdfc8c3
commit d9cd752f07
+37 -20
View File
@@ -479,26 +479,6 @@ void FilenameDB::FlushDirCache( const RString &sDir )
{
FileSet *pFileSet = NULL;
m_Mutex.Lock();
if( !sDir.empty() )
{
RString lower = sDir;
lower.MakeLower();
map<RString, FileSet *>::iterator it = dirs.find( lower );
if( it != dirs.end() )
{
pFileSet = it->second;
dirs.erase( it );
while( !pFileSet->m_bFilled )
m_Mutex.Wait();
delete pFileSet;
}
else
{
LOG->Warn( "Trying to flush an unknown directory %s.", sDir.c_str() );
}
m_Mutex.Unlock();
return;
}
while( true )
{
@@ -517,6 +497,43 @@ void FilenameDB::FlushDirCache( const RString &sDir )
m_Mutex.Wait();
delete pFileSet;
}
#if 0
/* XXX: This is tricky, we want to flush all of the subdirectories of
* sDir, but once we unlock the mutex, we basically have to start over.
* It's just an optimization though, so it can wait. */
{
if( it != dirs.end() )
{
pFileSet = it->second;
dirs.erase( it );
while( !pFileSet->m_bFilled )
m_Mutex.Wait();
delete pFileSet;
if( sDir != "/" )
{
RString sParent = Dirname( sDir );
if( sParent == "./" )
sParent = "";
sParent.MakeLower();
it = dirs.find( sParent );
if( it != dirs.end() )
{
FileSet *pParent = it->second;
set<File>::iterator fileit = pParent->files.find( File(Basename(sDir)) );
if( fileit != pParent->files.end() )
fileit->dirp = NULL;
}
}
}
else
{
LOG->Warn( "Trying to flush an unknown directory %s.", sDir.c_str() );
}
}
#endif
m_Mutex.Unlock();
}