From 8f7c4cbea43c145af46515bf553f69d04aedda62 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Tue, 11 Sep 2012 15:01:15 +0000 Subject: [PATCH] Bug fix race condition with thread::queue git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@6 a5eaa968-4c79-4d68-970d-af6011b5b055 --- connectors/vmware/centreon_esxd | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/connectors/vmware/centreon_esxd b/connectors/vmware/centreon_esxd index 5275a05ed..ca98a4537 100644 --- a/connectors/vmware/centreon_esxd +++ b/connectors/vmware/centreon_esxd @@ -1086,11 +1086,9 @@ sub vsphere_handler { } } - my $num_queued = $data_queue->pending(); - while ($num_queued) { - my $data_element = $data_queue->dequeue(); + my $data_element; + while (($data_element = $data_queue->dequeue_nb())) { chomp $data_element; - $num_queued--; if ($data_element =~ /^STOP$/) { $stop = 1; next; @@ -1171,9 +1169,9 @@ while (1) { ### # Check ### - my $num_queued = $response_queue->pending(); - while ($num_queued) { - my $data_element = $response_queue->dequeue(); + my $data_element; + + while (($data_element = $response_queue->dequeue_nb())) { chomp $data_element; if ($data_element =~ /^STOPPED$/) { writeLogFile("Thread has stopped\n"); @@ -1183,7 +1181,6 @@ while (1) { #print "Response queue = $data_element\n"; my @results = split(/\|/, $data_element); my $id = $results[0]; - $num_queued--; if (!defined($sockets{$id})) { writeLogFile("Too much time to get response.\n"); next;