Only load plugins when it is necessary

This commit is contained in:
Emmanuel Papin 2015-01-01 22:33:03 +01:00
parent cdfb4b4bb5
commit 8619ed1322
3 changed files with 28 additions and 22 deletions

View File

@ -433,9 +433,7 @@ Monitor::Monitor(
}
#if ZM_PLUGINS_ON
if ( purpose == ANALYSIS || purpose == QUERY )
{
if ( config.load_plugins || purpose == QUERY )
if ( config.load_plugins && ( ( purpose == ANALYSIS ) || ( purpose == QUERY_PLUGINS ) ) )
{
Info("Load plugins from the directory %s ... ", config.path_plugins);
ThePluginManager.setPluginExt(std::string(config.plugin_extension));
@ -458,12 +456,11 @@ Monitor::Monitor(
(!config.turnoff_native_analysis && iDoNativeMotDet));
}
}
}
#endif // ZM_PLUGINS_ON
if ( ( ! mem_ptr ) || ! shared_data->valid )
{
if ( purpose != QUERY )
if ( ( purpose != QUERY ) && ( purpose != QUERY_PLUGINS ) )
{
Error( "Shared data not initialised by capture daemon for monitor %s", name );
exit( -1 );

View File

@ -59,6 +59,7 @@ public:
typedef enum
{
QUERY=0,
QUERY_PLUGINS,
CAPTURE,
ANALYSIS
} Purpose;

View File

@ -426,7 +426,15 @@ int main( int argc, char *argv[] )
if ( mon_id > 0 )
{
Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES|ZMU_LIST_PLUG), Monitor::QUERY );
Monitor *monitor;
if ( function & ZMU_LIST_PLUG )
{
monitor = Monitor::Load( mon_id, false, Monitor::QUERY_PLUGINS );
}
else
{
monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY );
}
if ( monitor )
{
if ( verbose )