Use double eval for alarms as recommended by DBI(3)

This commit is contained in:
Xavier 2019-09-03 06:31:58 +02:00
parent e05d948ac4
commit 36ee1b80c2
3 changed files with 23 additions and 13 deletions

View File

@ -93,6 +93,9 @@ logLevel = warn
[configuration] [configuration]
; confTimeout: maximum time to get configuration (default 10)
;confTimeout = 5
; GLOBAL CONFIGURATION ACCESS TYPE ; GLOBAL CONFIGURATION ACCESS TYPE
; (File, REST, SOAP, RDBI/CDBI, LDAP, YAMLFile) ; (File, REST, SOAP, RDBI/CDBI, LDAP, YAMLFile)
; Set here the parameters needed to access to LemonLDAP::NG configuration. ; Set here the parameters needed to access to LemonLDAP::NG configuration.

View File

@ -403,9 +403,12 @@ sub _launch {
my $res; my $res;
eval { eval {
local $SIG{ALRM} = sub { die "TIMEOUT\n" }; local $SIG{ALRM} = sub { die "TIMEOUT\n" };
alarm ($self->{confTimeout} || 10); eval {
$res = &{ $self->{type} . "::$sub" }( $self, @_ ); alarm( $self->{confTimeout} || 10 );
$res = &{ $self->{type} . "::$sub" }( $self, @_ );
};
alarm 0; alarm 0;
die $@ if $@;
}; };
$msg .= $@ if $@; $msg .= $@ if $@;
return $res; return $res;

View File

@ -166,19 +166,23 @@ sub _tie_session {
eval { eval {
local $SIG{ALRM} = sub { die "TIMEOUT\n" }; local $SIG{ALRM} = sub { die "TIMEOUT\n" };
alarm $self->timeout; eval {
alarm $self->timeout;
# SOAP/REST session module must be directly tied # SOAP/REST session module must be directly tied
if ( $self->storageModule =~ /^Lemonldap::NG::Common::Apache::Session/ ) if ( $self->storageModule =~
{ /^Lemonldap::NG::Common::Apache::Session/ )
tie %h, $self->storageModule, $self->id, {
{ %{ $self->options }, %$options, kind => $self->kind }; tie %h, $self->storageModule, $self->id,
} { %{ $self->options }, %$options, kind => $self->kind };
else { }
tie %h, 'Lemonldap::NG::Common::Apache::Session', $self->id, else {
{ %{ $self->options }, %$options }; tie %h, 'Lemonldap::NG::Common::Apache::Session', $self->id,
} { %{ $self->options }, %$options };
}
};
alarm 0; alarm 0;
die $@ if $@;
}; };
if ( $@ or not tied(%h) ) { if ( $@ or not tied(%h) ) {