Bug fix race condition with thread::queue

git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@6 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2012-09-11 15:01:15 +00:00
parent ada37bcdbe
commit 8f7c4cbea4
1 changed files with 5 additions and 8 deletions

View File

@ -1086,11 +1086,9 @@ sub vsphere_handler {
} }
} }
my $num_queued = $data_queue->pending(); my $data_element;
while ($num_queued) { while (($data_element = $data_queue->dequeue_nb())) {
my $data_element = $data_queue->dequeue();
chomp $data_element; chomp $data_element;
$num_queued--;
if ($data_element =~ /^STOP$/) { if ($data_element =~ /^STOP$/) {
$stop = 1; $stop = 1;
next; next;
@ -1171,9 +1169,9 @@ while (1) {
### ###
# Check # Check
### ###
my $num_queued = $response_queue->pending(); my $data_element;
while ($num_queued) {
my $data_element = $response_queue->dequeue(); while (($data_element = $response_queue->dequeue_nb())) {
chomp $data_element; chomp $data_element;
if ($data_element =~ /^STOPPED$/) { if ($data_element =~ /^STOPPED$/) {
writeLogFile("Thread has stopped\n"); writeLogFile("Thread has stopped\n");
@ -1183,7 +1181,6 @@ while (1) {
#print "Response queue = $data_element\n"; #print "Response queue = $data_element\n";
my @results = split(/\|/, $data_element); my @results = split(/\|/, $data_element);
my $id = $results[0]; my $id = $results[0];
$num_queued--;
if (!defined($sockets{$id})) { if (!defined($sockets{$id})) {
writeLogFile("Too much time to get response.\n"); writeLogFile("Too much time to get response.\n");
next; next;