Set @Parser::Expat::Encoding_Path instead of calling load_encoding.

Parser::Expat::load_encoding doesn't seem to be thread safe. Set
@Parser::Expat::Encoding_Path instead to avoid problems.

Ref pandora_enterprise#1340.
This commit is contained in:
Ramon Novoa 2017-09-28 15:16:32 +02:00
parent ebe1f37bf9
commit 96a3dfab43
1 changed files with 2 additions and 20 deletions

View File

@ -73,26 +73,8 @@ sub new ($$;$) {
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);
# Load external .enc files for XML::Parser. # Load external .enc files for XML::Parser.
if ($config->{'enc_dir'} ne '') { if ($config->{'enc_dir'} ne '' && !grep {$_ eq $config->{'enc_dir'}} @XML::Parser::Expat::Encoding_Path) {
if (opendir(my $dh, $config->{'enc_dir'})) { push(@XML::Parser::Expat::Encoding_Path, $config->{'enc_dir'});
while (my $enc_file = readdir($dh)) {
# Ignore unknown files.
next unless ($enc_file =~ m/.enc$/);
# Load the .enc file.
eval {
local $SIG{__DIE__} = {};
XML::Parser::Expat::load_encoding($config->{'enc_dir'} . '/' . $enc_file);
};
if ($@) {
print_message ($config, " [WARNING] Error loading encoding file: $enc_file", 1);
}
}
closedir($dh);
} else {
print_message($config, " [WARNING] Error opening directory " . $config->{'enc_dir'} . ": $!", 1);
}
} }
bless $self, $class; bless $self, $class;