Limit FSWatcher
Library watches only need a single directory or immediate children. The project watcher should have a sensible limit to the total number of files it tries to track. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15717
This commit is contained in:
parent
68c0be1097
commit
42ebf0eca5
|
@ -111,6 +111,7 @@ static const wxChar TriangulateSimplificationLevel[] = wxT( "TriangulateSimplifi
|
||||||
static const wxChar TriangulateMinimumArea[] = wxT( "TriangulateMinimumArea" );
|
static const wxChar TriangulateMinimumArea[] = wxT( "TriangulateMinimumArea" );
|
||||||
static const wxChar EnableCacheFriendlyFracture[] = wxT( "EnableCacheFriendlyFracture" );
|
static const wxChar EnableCacheFriendlyFracture[] = wxT( "EnableCacheFriendlyFracture" );
|
||||||
static const wxChar EnableAPILogging[] = wxT( "EnableAPILogging" );
|
static const wxChar EnableAPILogging[] = wxT( "EnableAPILogging" );
|
||||||
|
static const wxChar MaxFileSystemWatchers[] = wxT( "MaxFileSystemWatchers" );
|
||||||
} // namespace KEYS
|
} // namespace KEYS
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,6 +266,8 @@ ADVANCED_CFG::ADVANCED_CFG()
|
||||||
|
|
||||||
m_EnableCacheFriendlyFracture = true;
|
m_EnableCacheFriendlyFracture = true;
|
||||||
|
|
||||||
|
m_MaxFilesystemWatchers = 16384;
|
||||||
|
|
||||||
loadFromConfigFile();
|
loadFromConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,6 +490,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
||||||
&m_EnableCacheFriendlyFracture,
|
&m_EnableCacheFriendlyFracture,
|
||||||
m_EnableCacheFriendlyFracture ) );
|
m_EnableCacheFriendlyFracture ) );
|
||||||
|
|
||||||
|
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::MaxFileSystemWatchers,
|
||||||
|
&m_MaxFilesystemWatchers, m_MaxFilesystemWatchers,
|
||||||
|
0, 2147483647 ) );
|
||||||
|
|
||||||
// Special case for trace mask setting...we just grab them and set them immediately
|
// Special case for trace mask setting...we just grab them and set them immediately
|
||||||
// Because we even use wxLogTrace inside of advanced config
|
// Because we even use wxLogTrace inside of advanced config
|
||||||
wxString traceMasks;
|
wxString traceMasks;
|
||||||
|
|
|
@ -688,7 +688,7 @@ void SCH_BASE_FRAME::setSymWatcher( const LIB_ID* aID )
|
||||||
fn.AssignDir( m_watcherFileName.GetPath() );
|
fn.AssignDir( m_watcherFileName.GetPath() );
|
||||||
fn.DontFollowLink();
|
fn.DontFollowLink();
|
||||||
|
|
||||||
m_watcher->AddTree( fn );
|
m_watcher->Add( fn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -580,6 +580,16 @@ public:
|
||||||
* Log IPC API requests and responses
|
* Log IPC API requests and responses
|
||||||
*/
|
*/
|
||||||
bool m_EnableAPILogging;
|
bool m_EnableAPILogging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of filesystem watchers to use.
|
||||||
|
*
|
||||||
|
* Setting name: "MaxFilesystemWatchers"
|
||||||
|
* Valid values: 0 to 2147483647
|
||||||
|
* Default value: 16384
|
||||||
|
*/
|
||||||
|
int m_MaxFilesystemWatchers;
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1435,8 +1435,9 @@ void PROJECT_TREE_PANE::FileWatcherReset()
|
||||||
std::stack < wxTreeItemId > subdirs_id;
|
std::stack < wxTreeItemId > subdirs_id;
|
||||||
|
|
||||||
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
||||||
|
int total_watch_count = 0;
|
||||||
|
|
||||||
while( true )
|
while( total_watch_count < ADVANCED_CFG::GetCfg().m_MaxFilesystemWatchers )
|
||||||
{
|
{
|
||||||
if( !kid.IsOk() )
|
if( !kid.IsOk() )
|
||||||
{
|
{
|
||||||
|
@ -1468,6 +1469,7 @@ void PROJECT_TREE_PANE::FileWatcherReset()
|
||||||
{
|
{
|
||||||
fn.AssignDir( path );
|
fn.AssignDir( path );
|
||||||
m_watcher->Add( fn );
|
m_watcher->Add( fn );
|
||||||
|
total_watch_count++;
|
||||||
|
|
||||||
// if kid is a subdir, push in list to explore it later
|
// if kid is a subdir, push in list to explore it later
|
||||||
if( itemData->IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
|
if( itemData->IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
|
||||||
|
@ -1479,6 +1481,9 @@ void PROJECT_TREE_PANE::FileWatcherReset()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if( total_watch_count >= ADVANCED_CFG::GetCfg().m_MaxFilesystemWatchers )
|
||||||
|
wxLogTrace( tracePathsAndFiles, "%s: too many directories to watch\n", __func__ );
|
||||||
|
|
||||||
#if defined(DEBUG) && 1
|
#if defined(DEBUG) && 1
|
||||||
wxArrayString paths;
|
wxArrayString paths;
|
||||||
m_watcher->GetWatchedPaths( &paths );
|
m_watcher->GetWatchedPaths( &paths );
|
||||||
|
|
|
@ -1185,7 +1185,7 @@ void PCB_BASE_FRAME::setFPWatcher( FOOTPRINT* aFootprint )
|
||||||
|
|
||||||
wxLogTrace( "KICAD_LIB_WATCH", "Add watch: %s", fn.GetPath() );
|
wxLogTrace( "KICAD_LIB_WATCH", "Add watch: %s", fn.GetPath() );
|
||||||
|
|
||||||
m_watcher->AddTree( fn );
|
m_watcher->Add( fn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue