diff --git a/Changes b/Changes index f18734cd3..e465803d0 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ Revision history for GLPI agent 1.8 not yet released +core: +* Parallel::ForkManager must not use more than 60 workers on MSWin32 due to a + perl limitation on this operating system + inventory: * Fix network default route discovery on linux * Fix virtualmachine inventory on computer providing vmware-cmd command diff --git a/lib/GLPI/Agent/HTTP/Server/ToolBox/Remotes.pm b/lib/GLPI/Agent/HTTP/Server/ToolBox/Remotes.pm index 0284e0725..ad9471259 100644 --- a/lib/GLPI/Agent/HTTP/Server/ToolBox/Remotes.pm +++ b/lib/GLPI/Agent/HTTP/Server/ToolBox/Remotes.pm @@ -356,7 +356,7 @@ sub _submit_start { my $logger = $self->{logger}; my $starttime = gettimeofday(); - # Configure agent to use required workes and only process expired remotes + # Configure agent to use required workers and only process expired remotes $agent->{config}->{'remote-workers'} = $workers || 1; $agent->{config}->{'remote-scheduling'} = 1; diff --git a/lib/GLPI/Agent/Task/Deploy/P2P.pm b/lib/GLPI/Agent/Task/Deploy/P2P.pm index e4f7c21e2..499907b57 100644 --- a/lib/GLPI/Agent/Task/Deploy/P2P.pm +++ b/lib/GLPI/Agent/Task/Deploy/P2P.pm @@ -28,6 +28,12 @@ sub new { p2pnet => {} }; + # On windows, max_workers should not be bigger than 60 due to a perl limitation + if ($OSNAME eq 'MSWin32' && $self->{max_workers} > 60) { + $self->{logger}->info("Limiting workers from $self->{max_workers} to 60 on MSWin32"); + $self->{max_workers} = 60; + } + bless $self, $class; return $self; diff --git a/lib/GLPI/Agent/Task/NetDiscovery.pm b/lib/GLPI/Agent/Task/NetDiscovery.pm index f038a6ab4..ef523d756 100644 --- a/lib/GLPI/Agent/Task/NetDiscovery.pm +++ b/lib/GLPI/Agent/Task/NetDiscovery.pm @@ -167,6 +167,12 @@ sub run { my ($max_threads) = sort { $b <=> $a } map { int($_->max_threads()) } @{$self->{jobs}}; + # On windows, max_threads should not be upper than 60 due to a perl limitation + if ($OSNAME eq 'MSWin32' && $max_threads > 60) { + $self->{logger}->info("Limiting threads from $max_threads to 60 on MSWin32"); + $max_threads = 60; + } + # Prepare fork manager my $tempdir = $self->{target}->getStorage()->getDirectory(); mkpath($tempdir); diff --git a/lib/GLPI/Agent/Task/NetInventory.pm b/lib/GLPI/Agent/Task/NetInventory.pm index b9dc526ad..5572a8b87 100644 --- a/lib/GLPI/Agent/Task/NetInventory.pm +++ b/lib/GLPI/Agent/Task/NetInventory.pm @@ -120,6 +120,12 @@ sub run { my ($max_threads) = sort { $b <=> $a } map { int($_->max_threads()) } @{$self->{jobs}}; + # On windows, max_threads should not be upper than 60 due to a perl limitation + if ($OSNAME eq 'MSWin32' && $max_threads > 60) { + $self->{logger}->info("Limiting threads from $max_threads to 60 on MSWin32"); + $max_threads = 60; + } + # count devices and check skip_start_stop my $devices_count = 0; my $skip_start_stop = 0; diff --git a/lib/GLPI/Agent/Task/RemoteInventory.pm b/lib/GLPI/Agent/Task/RemoteInventory.pm index fe390237f..e34ef04b9 100644 --- a/lib/GLPI/Agent/Task/RemoteInventory.pm +++ b/lib/GLPI/Agent/Task/RemoteInventory.pm @@ -5,6 +5,7 @@ use warnings; use parent 'GLPI::Agent::Task::Inventory'; +use English qw(-no_match_vars); use Parallel::ForkManager; use GLPI::Agent::Tools; @@ -49,6 +50,12 @@ sub run { my $worker_count = $remotes->count() > 1 ? $self->{config}->{'remote-workers'} : 0; + # On windows, worker_count should not be upper than 60 due to a perl limitation + if ($OSNAME eq 'MSWin32' && $worker_count > 60) { + $self->{logger}->info("Limiting workers count from $worker_count to 60 on MSWin32"); + $worker_count = 60; + } + my $start = time; my $manager = Parallel::ForkManager->new($worker_count);