@@ -, +, @@ if need be --- C4/SIP/ILS/Patron.pm | 11 +++++++++-- C4/SIP/Sip/MsgType.pm | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) --- a/C4/SIP/ILS/Patron.pm +++ a/C4/SIP/ILS/Patron.pm @@ -14,6 +14,7 @@ use Carp; use Sys::Syslog qw(syslog); use Data::Dumper; +use Time::Out qw(timeout); use C4::Debug; use C4::Context; @@ -199,9 +200,15 @@ sub check_password { # If the record has a NULL password, accept '' as match return $pwd eq q{} unless $self->{password}; - my $dbh = C4::Context->dbh; my $ret = 0; - ($ret) = checkpw( $dbh, $self->{userid}, $pwd, undef, undef, 1 ); # dbh, userid, query, type, no_set_userenv + local $@; + ($ret) = timeout (5 => sub { + # dbh, userid, query, type, no_set_userenv + checkpw( C4::Context->dbh, $self->{userid}, $pwd, undef, undef, 1 ); + }); + if ($@) { + ($ret) = checkpw( C4::Context->new_dbh, $self->{userid}, $pwd, undef, undef, 1 ); + } return $ret; } --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -10,6 +10,7 @@ use strict; use warnings; use Exporter; use Sys::Syslog qw(syslog); +use Time::Out qw(timeout); use C4::SIP::Sip qw(:all); use C4::SIP::Sip::Constants qw(:all); @@ -1607,7 +1608,15 @@ sub api_auth { if ($branch) { $query->param( branch => $branch ); } - my ( $status, $cookie, $sessionID ) = check_api_auth( $query, { circulate => 1 }, 'intranet' ); + + local $@; + my ( $status, $cookie, $sessionID ) = timeout (5 => sub { + check_api_auth( $query, { circulate => 1 }, 'intranet' ); + }); + if ($@) { + C4::Context->new_dbh; + ( $status, $cookie, $sessionID ) = check_api_auth( $query, { circulate => 1 }, 'intranet' ); + } return $status; } --