diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 2e56ba0351..37e5283e39 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2011-02-10 Ramon Novoa + + * pandora_agent: Detach threads to avoid excessive resource usage, + since threads were not joined until all modules were executed. + 2011-02-01 Junichi Satoh * FreeBSD/pandora_agent.conf: Fixed invalid cpu usage data is returned diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 073f60af3a..4cbf031866 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -39,9 +39,6 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -# Thread list -my @Threads; - # Load thread support eval { local $SIG{__DIE__}; @@ -1403,7 +1400,7 @@ while (1) { if (! defined ($thr)) { $ThreadSem->up (); } else { - push (@Threads, $thr); + $thr->detach(); } # Execute the module } else { @@ -1421,7 +1418,7 @@ while (1) { if (! defined ($thr)) { $ThreadSem->up (); } else { - push (@Threads, $thr); + $thr->detach(); } # Execute the plugin } else { @@ -1430,11 +1427,9 @@ while (1) { } # Wait for all the threads - foreach my $thread (@Threads) { - $thread->join (); - } - @Threads = (); - + $ThreadSem->down ($Conf{'agent_threads'}) if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + $ThreadSem->up ($Conf{'agent_threads'}) if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + $Xml .= ""; # Save XML data file