Merge branch 'ent-4489-revision-comportamiento-pandora_server-e7' into 'develop'
Ent 4489 revision comportamiento pandora server e7 See merge request artica/pandorafms!2696
This commit is contained in:
commit
bc00f7d7b6
|
@ -58,6 +58,7 @@ my %Agents :shared;
|
||||||
my $Sem :shared;
|
my $Sem :shared;
|
||||||
my $TaskSem :shared;
|
my $TaskSem :shared;
|
||||||
my $AgentSem :shared;
|
my $AgentSem :shared;
|
||||||
|
my $XMLinSem :shared;
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
# Data Server class constructor.
|
# Data Server class constructor.
|
||||||
|
@ -74,6 +75,7 @@ sub new ($$;$) {
|
||||||
$Sem = Thread::Semaphore->new;
|
$Sem = Thread::Semaphore->new;
|
||||||
$TaskSem = Thread::Semaphore->new (0);
|
$TaskSem = Thread::Semaphore->new (0);
|
||||||
$AgentSem = Thread::Semaphore->new (1);
|
$AgentSem = Thread::Semaphore->new (1);
|
||||||
|
$XMLinSem = Thread::Semaphore->new (1);
|
||||||
|
|
||||||
# Call the constructor of the parent class
|
# Call the constructor of the parent class
|
||||||
my $self = $class->SUPER::new($config, DATASERVER, \&PandoraFMS::DataServer::data_producer, \&PandoraFMS::DataServer::data_consumer, $dbh);
|
my $self = $class->SUPER::new($config, DATASERVER, \&PandoraFMS::DataServer::data_producer, \&PandoraFMS::DataServer::data_consumer, $dbh);
|
||||||
|
@ -175,6 +177,7 @@ sub data_consumer ($$) {
|
||||||
my $agent_name = $1;
|
my $agent_name = $1;
|
||||||
my $file_name = $pa_config->{'incomingdir'};
|
my $file_name = $pa_config->{'incomingdir'};
|
||||||
my $xml_err;
|
my $xml_err;
|
||||||
|
my $error;
|
||||||
|
|
||||||
# Fix path
|
# Fix path
|
||||||
$file_name .= "/" unless (substr ($file_name, -1, 1) eq '/');
|
$file_name .= "/" unless (substr ($file_name, -1, 1) eq '/');
|
||||||
|
@ -191,18 +194,37 @@ sub data_consumer ($$) {
|
||||||
|
|
||||||
for (0..1) {
|
for (0..1) {
|
||||||
eval {
|
eval {
|
||||||
|
local $SIG{__DIE__};
|
||||||
threads->yield;
|
threads->yield;
|
||||||
|
# XML::SAX::ExpatXS is not thread safe.
|
||||||
|
if ($XML::Simple::PREFERRED_PARSER eq 'XML::SAX::ExpatXS') {
|
||||||
|
$XMLinSem->down();
|
||||||
|
}
|
||||||
|
|
||||||
$xml_data = XMLin ($file_name, forcearray => 'module');
|
$xml_data = XMLin ($file_name, forcearray => 'module');
|
||||||
|
|
||||||
|
if ($XML::Simple::PREFERRED_PARSER eq 'XML::SAX::ExpatXS') {
|
||||||
|
$XMLinSem->up();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
# Invalid XML
|
# Invalid XML
|
||||||
if ($@ || ref($xml_data) ne 'HASH') {
|
if ($@) {
|
||||||
|
$error = 1;
|
||||||
|
if ($XML::Simple::PREFERRED_PARSER eq 'XML::SAX::ExpatXS') {
|
||||||
|
$XMLinSem->up();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error || ref($xml_data) ne 'HASH') {
|
||||||
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$xml_err = $@;
|
$xml_err = $@;
|
||||||
} else {
|
} else {
|
||||||
$xml_err = "Invalid XML format.";
|
$xml_err = "Invalid XML format.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger($pa_config, "Failed to parse $file_name $xml_err", 3);
|
||||||
sleep (2);
|
sleep (2);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue