mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
Fix #2086
This commit is contained in:
parent
96bd72bce2
commit
490030ab3d
@ -72,11 +72,15 @@ sub new {
|
||||
# Sometimes, we need to set ENV
|
||||
$self->{env} = undef;
|
||||
|
||||
$self->set_signal_handlers();
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prepare_destroy {
|
||||
my ($self) = @_;
|
||||
|
||||
%handlers = ();
|
||||
}
|
||||
|
||||
sub set_signal_handlers {
|
||||
my $self = shift;
|
||||
|
||||
@ -93,6 +97,7 @@ sub class_handle_ALRM {
|
||||
sub handle_ALRM {
|
||||
my $self = shift;
|
||||
|
||||
$self->prepare_destroy();
|
||||
$self->disconnect();
|
||||
$self->{output}->output_add(severity => $self->{sql_errors_exit},
|
||||
short_msg => 'Timeout');
|
||||
@ -214,6 +219,7 @@ sub connect {
|
||||
}
|
||||
}
|
||||
|
||||
$self->set_signal_handlers();
|
||||
alarm($self->{timeout}) if (defined($self->{timeout}));
|
||||
$self->{instance} = DBI->connect(
|
||||
"DBI:". $self->{data_source},
|
||||
@ -222,6 +228,7 @@ sub connect {
|
||||
{ RaiseError => 0, PrintError => 0, AutoCommit => 1, %{$self->{connect_options_hash}} }
|
||||
);
|
||||
alarm(0) if (defined($self->{timeout}));
|
||||
$self->prepare_destroy();
|
||||
|
||||
if (!defined($self->{instance})) {
|
||||
my $err_msg = sprintf('Cannot connect: %s', defined($DBI::errstr) ? $DBI::errstr : '(no error string)');
|
||||
|
Loading…
x
Reference in New Issue
Block a user