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:
@@ -479,26 +479,6 @@ void FilenameDB::FlushDirCache( const RString &sDir )
|
|||||||
{
|
{
|
||||||
FileSet *pFileSet = NULL;
|
FileSet *pFileSet = NULL;
|
||||||
m_Mutex.Lock();
|
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 )
|
while( true )
|
||||||
{
|
{
|
||||||
@@ -517,6 +497,43 @@ void FilenameDB::FlushDirCache( const RString &sDir )
|
|||||||
m_Mutex.Wait();
|
m_Mutex.Wait();
|
||||||
delete pFileSet;
|
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();
|
m_Mutex.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user