From 97ce49dc672e3692b27c1e71ca00c4d95e11c0a8 Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Tue, 12 Dec 2023 11:56:03 +0100 Subject: [PATCH] fix: Fix possible concurrency error leading to a netdiscovery or netinventory blocked task --- Changes | 1 + lib/GLPI/Agent/Task/NetDiscovery.pm | 4 +++- lib/GLPI/Agent/Task/NetInventory.pm | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index bb2a44c3d..8f16347a6 100644 --- a/Changes +++ b/Changes @@ -33,6 +33,7 @@ netdiscovery/netinventory: * Fix LLDP support * Update timeout to backend-collect-timeout configuration when scanning ESX or RemoteInventory after a successful scan requested by ToolBox +* Fix possible concurrency error leading to an unrecoverable blocked task esx: * Fix first connection timeout support diff --git a/lib/GLPI/Agent/Task/NetDiscovery.pm b/lib/GLPI/Agent/Task/NetDiscovery.pm index efaa3f13e..d19526d8c 100644 --- a/lib/GLPI/Agent/Task/NetDiscovery.pm +++ b/lib/GLPI/Agent/Task/NetDiscovery.pm @@ -300,7 +300,9 @@ sub run { # Enqueue as ip as possible for each job foreach my $jobid (@jobs) { - my $job = $jobs{$jobid}; + # job may has just been done & deleted in run_on_finish() manager callback + my $job = $jobs{$jobid} + or next; next unless $job->ranges; next if $job->max_in_queue; my $range = $job->range; diff --git a/lib/GLPI/Agent/Task/NetInventory.pm b/lib/GLPI/Agent/Task/NetInventory.pm index 9abedf355..5025cd16b 100644 --- a/lib/GLPI/Agent/Task/NetInventory.pm +++ b/lib/GLPI/Agent/Task/NetInventory.pm @@ -209,7 +209,9 @@ sub run { # Enqueue as device as possible for each job foreach my $pid (@pids) { - my $job = $jobs{$pid}; + # job may has just been done & deleted in run_on_finish() manager callback + my $job = $jobs{$pid} + or next; next if $job->no_more || $job->max_in_queue; my $device = $job->nextdevice or next;