| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rose::DBx::Cache::Anywhere; |
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
73
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use base qw( Rose::DB::Cache ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
416
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Rose::DBx::Cache::Anywhere - get Apache::DBI behaviour without Apache |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This class is used by Rose::DBx::AutoReconnect. |
|
14
|
|
|
|
|
|
|
The author uses |
|
15
|
|
|
|
|
|
|
Rose::DB with Catalyst under both the Catalyst dev server and |
|
16
|
|
|
|
|
|
|
FastCGI and found that the standard Rose::DB::Cache behaviour |
|
17
|
|
|
|
|
|
|
did not work well with those environments. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 prepare_db( I, I ) |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Overrides default method to always ping() dbh if not running |
|
24
|
|
|
|
|
|
|
under mod_perl. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub prepare_db { |
|
29
|
0
|
|
|
0
|
1
|
|
my ( $self, $db, $entry ) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
$db->debug && $db->logger("prepare_db for entry $entry"); |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
if ( Rose::DB::Cache::MOD_PERL_1 || Rose::DB::Cache::MOD_PERL_2 ) { |
|
34
|
|
|
|
|
|
|
return $self->SUPER::prepare_db( $db, $entry ); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ( !$entry->is_prepared ) { |
|
38
|
0
|
0
|
|
|
|
|
if ( $entry->created_during_apache_startup ) { |
|
39
|
0
|
0
|
|
|
|
|
if ( $db->has_dbh ) { |
|
40
|
0
|
0
|
|
|
|
|
$db->debug |
|
41
|
|
|
|
|
|
|
&& $db->logger( "$$ Disconnecting and undef-ing dbh " |
|
42
|
|
|
|
|
|
|
. $db->dbh |
|
43
|
|
|
|
|
|
|
. " created during apache startup from $db" ); |
|
44
|
0
|
|
|
|
|
|
eval { $db->dbh->disconnect }; # will probably fail! |
|
|
0
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$@ |
|
46
|
|
|
|
|
|
|
&& $db->logger( |
|
47
|
|
|
|
|
|
|
"$$ Could not disconnect dbh created during apache startup: " |
|
48
|
|
|
|
|
|
|
. $db->dbh |
|
49
|
|
|
|
|
|
|
. " - $@" ); |
|
50
|
0
|
|
|
|
|
|
$db->dbh(undef); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$entry->created_during_apache_startup(0); |
|
54
|
0
|
|
|
|
|
|
return; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$entry->prepared(1); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ( !$db->dbh->ping ) { |
|
61
|
0
|
|
|
|
|
|
$db->logger("dbh->ping failed ... unsetting dbh for automatic retry"); |
|
62
|
0
|
|
|
|
|
|
$db->dbh(undef); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |