Lines 818-832
sub dbh
Link Here
|
818 |
my $sth; |
818 |
my $sth; |
819 |
|
819 |
|
820 |
unless ( $params->{new} ) { |
820 |
unless ( $params->{new} ) { |
821 |
if ( defined($context->{db_driver}) && $context->{db_driver} eq 'mysql' && $context->{"dbh"} ) { |
821 |
if (defined($context->{"dbh"})) { |
822 |
return $context->{"dbh"}; |
822 |
#If there has been more than 4 minutes since we got a fresh and working DBI-connection, make sure it is still alive |
823 |
} elsif ( defined($context->{"dbh"}) && $context->{"dbh"}->ping() ) { |
823 |
#The mysql_auto_reconnect, parameter doesn't seem to work properly in all environments. |
824 |
return $context->{"dbh"}; |
824 |
if ($context->{"dbhCreatedTimestamp"} < (time()-240)) { |
|
|
825 |
if ($context->{"dbh"}->ping() eq '0') { |
826 |
return $context->{"dbh"}; |
827 |
$context->{"dbhCreatedTimestamp"} = time(); #I hope we now really have a working connection, since ping() is occasionally iffy. |
828 |
} |
829 |
} |
830 |
else { |
831 |
return $context->{"dbh"}; |
832 |
} |
825 |
} |
833 |
} |
826 |
} |
834 |
} |
827 |
|
835 |
|
828 |
# No database handle or it died . Create one. |
836 |
# No database handle or it died . Create one. |
829 |
$context->{"dbh"} = &_new_dbh(); |
837 |
$context->{"dbh"} = &_new_dbh(); |
|
|
838 |
$context->{"dbhCreatedTimestamp"} = time(); |
830 |
|
839 |
|
831 |
return $context->{"dbh"}; |
840 |
return $context->{"dbh"}; |
832 |
} |
841 |
} |
833 |
- |
|
|