| 1 | # $Id: AutoReconnect.pm,v 1.4 2005/12/01 18:09:52 dk Exp $ | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package DBIx::Roles::AutoReconnect; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use DBIx::Roles; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw(%defaults $VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | $VERSION = '1.00'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | %defaults = ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | ReconnectTimeout => 60, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | ReconnectMaxTries => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ReconnectFailure => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | sub initialize | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | return [], \%defaults; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub connect | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | my ( $self, $conninfo, $dsn, $user, $pass, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | @$conninfo = ( $dsn, $user, $pass, $attr ); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | my ( $super, $private) = $self-> get_super; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | ▶ | return unless $super; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | my $dbh = db_connect( $self, $conninfo, $super, $private); | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | return $dbh; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub db_connect | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
db_connect: called CC=15 SCAR=37.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | my ( $self, $conninfo, $ref, @param) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | my $attr = $self-> {attr}; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | my $tries = 0; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | my $downtime = 0; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | my $ret; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | RETRY: while ( 1) { | |||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 9 | my $context = $self-> context; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | local $conninfo->[3]->{RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 9 | $ret = $ref->( $self, @param, @$conninfo); | |||||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | ▶ | if ( $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | # restore context if calls are restarted | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | $self-> context( $context); | |||||||||||||||||||||||||||||||||||||||||
| 55 | } elsif ( $ret) { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | warn "DBIx::Roles::AutoReconnect: successfully reconnected after $tries tries and $downtime sec downtime\n" | ||||||||||||||||||||||||||||||||||||||||||
| 57 | if $tries > 0 and ( | ||||||||||||||||||||||||||||||||||||||||||
| 58 | $conninfo->[3]-> {PrintError} or | ||||||||||||||||||||||||||||||||||||||||||
| 59 | not (exists $conninfo->[3]->{PrintError}) # DBI defaults | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$tries > 0 and $conninfo->[3]{"PrintError"} || !exists $conninfo->[3]{"PrintError"}
$conninfo->[3]{"PrintError"} or not exists $conninfo->[3]{"PrintError"}
MC/DC0%0/3
$tries > 0 and $conninfo->[3]{"PrintError"} || !exists $conninfo->[3]{"PrintError"}
$tries > 0
$conninfo->[3]{"PrintError"}
not exists $conninfo->[3]{"PrintError"}
Truth table50%2/4
A and B or not(C)
A= $tries > 0B= $conninfo->[3]{"PrintError"}C= not exists $conninfo->[3]{"PrintError"}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | last RETRY; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $@ = "DBIx::Roles::AutoReconnect: Cannot connect(): no suitable roles found"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | $attr-> {ReconnectFailure}->() | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | if $attr-> {ReconnectFailure}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | $tries++; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attr->{"ReconnectMaxTries"} and $attr->{"ReconnectMaxTries"} <= $tries
MC/DC0%0/2
defined $attr->{"ReconnectMaxTries"} and $attr->{"ReconnectMaxTries"} <= $tries
defined $attr->{"ReconnectMaxTries"}
$attr->{"ReconnectMaxTries"} <= $tries
Truth table33%1/3
A and B
A= defined $attr->{"ReconnectMaxTries"}B= $attr->{"ReconnectMaxTries"} <= $tries
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | defined ($attr-> {ReconnectMaxTries}) and | ||||||||||||||||||||||||||||||||||||||||||
| 71 | $attr-> {ReconnectMaxTries} <= $tries | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $@ = "DBIx::Roles::AutoReconnect: Tried to connect $attr->{ReconnectMaxTries} time(s), giving up\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | unless $@; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( $conninfo-> [3]-> {RaiseError}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | warn $@ if | ||||||||||||||||||||||||||||||||||||||||||
| 79 | not (exists $conninfo->[3]->{PrintError}) # DBI defaults | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | or $conninfo->[3]->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
MC/DC0%0/2
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
not exists $conninfo->[3]{"PrintError"}
$conninfo->[3]{"PrintError"}
Truth table0%0/3
not(A) or B
A= not exists $conninfo->[3]{"PrintError"}B= $conninfo->[3]{"PrintError"}
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | if ( $attr-> {ReconnectTimeout} > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | warn "DBIx::AutoReconnect: sleeping for $attr->{ReconnectTimeout} seconds\n" | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if $conninfo-> [3]->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | sleep $attr-> {ReconnectTimeout}; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $downtime += $attr-> {ReconnectTimeout}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub dbi_method | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbi_method: called CC=18 SCAR=41.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 11 | my ( $self, $conninfo, $method, @parameters) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | return $self-> super( $method, @parameters) | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 11 | ▶ | if $method eq 'connect' or not $self->dbh->{AutoCommit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$method eq "connect" or not $self->dbh->{"AutoCommit"}
MC/DC50%1/2
$method eq "connect" or not $self->dbh->{"AutoCommit"}
$method eq "connect"
not $self->dbh->{"AutoCommit"}
Truth table66%2/3
A or not(B)
A= $method eq "connect"B= not $self->dbh->{"AutoCommit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my ( $wantarray, @ret) = ( wantarray); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | my ( $super, $private) = $self-> get_super; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | return unless $super; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my $tries = 0; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | while ( 1) { | |||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"attr"}{"ReconnectMaxTries"} and $self->{"attr"}{"ReconnectMaxTries"} <= $tries
MC/DC0%0/2
defined $self->{"attr"}{"ReconnectMaxTries"} and $self->{"attr"}{"ReconnectMaxTries"} <= $tries
defined $self->{"attr"}{"ReconnectMaxTries"}
$self->{"attr"}{"ReconnectMaxTries"} <= $tries
Truth table33%1/3
A and B
A= defined $self->{"attr"}{"ReconnectMaxTries"}B= $self->{"attr"}{"ReconnectMaxTries"} <= $tries
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | defined ($self->{attr}-> {ReconnectMaxTries}) and | ||||||||||||||||||||||||||||||||||||||||||
| 110 | $self->{attr}-> {ReconnectMaxTries} <= $tries | ||||||||||||||||||||||||||||||||||||||||||
| 111 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ( $conninfo-> [3]-> {RaiseError}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | die "DBIx::Roles::AutoReconnect: Tried to call '$method' $self->{attr}->{ReconnectMaxTries} time(s), giving up\n"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | warn "DBIx::Roles::AutoReconnect: Tried to call '$method' $self->{attr}->{ReconnectMaxTries} time(s), giving up\n" if | ||||||||||||||||||||||||||||||||||||||||||
| 116 | not exists ($conninfo->[3]->{PrintError}) # DBI defaults | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | or $conninfo->[3]->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
MC/DC0%0/2
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
not exists $conninfo->[3]{"PrintError"}
$conninfo->[3]{"PrintError"}
Truth table0%0/3
not(A) or B
A= not exists $conninfo->[3]{"PrintError"}B= $conninfo->[3]{"PrintError"}
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | $tries++; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | unless ( $self-> dbh) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | $conninfo-> [3]-> {RaiseError} ? | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | croak( "DBIx::Roles::AutoReconnect: not connected" ) : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # repeatedly call the roles below until they succeed | ||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | local $self-> object-> {RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | my $context = $self-> context; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | if ( $wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | @ret = $super-> ($self, $private, $method, @parameters); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 4 | $ret[0] = $super-> ($self, $private, $method, @parameters); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | return wantarray ? @ret : $ret[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | unless $@; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # restore context if calls are restarted | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $self-> context( $context); | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | if ( $self-> dbh-> ping) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | # DB is alive, most probably that was not a DBI-related error | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( $conninfo-> [3]-> {RaiseError}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | warn $@ if | ||||||||||||||||||||||||||||||||||||||||||
| 150 | not (exists $conninfo->[3]->{PrintError}) # DBI defaults | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | or $conninfo->[3]->{PrintError}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
MC/DC0%0/2
not exists $conninfo->[3]{"PrintError"} or $conninfo->[3]{"PrintError"}
not exists $conninfo->[3]{"PrintError"}
$conninfo->[3]{"PrintError"}
Truth table0%0/3
not(A) or B
A= not exists $conninfo->[3]{"PrintError"}B= $conninfo->[3]{"PrintError"}
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # without disconnect | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $self-> dbh( $self-> connect( @$conninfo)); | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=9 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 17 | my ( $self, $conninfo, $key, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 17 | ▶ | if ( $key eq 'ReconnectTimeout' or $key eq 'ReconnectMaxTries') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$key eq "ReconnectTimeout" or $key eq "ReconnectMaxTries"
MC/DC100%2/2
$key eq "ReconnectTimeout" or $key eq "ReconnectMaxTries"
$key eq "ReconnectTimeout"
$key eq "ReconnectMaxTries"
Truth table100%3/3
A or B
A= $key eq "ReconnectTimeout"B= $key eq "ReconnectMaxTries"
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | ▶ | die "Fatal: '$key' must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | unless $val =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | } elsif ( $key eq 'ReconnectFailure') { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | die "Fatal: '$key' must be either 'undef' or a CODE reference" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not defined $val && ref $val or ref $val ne "CODE"
defined $val && ref $val
MC/DC0%0/3
not defined $val && ref $val or ref $val ne "CODE"
defined $val
ref $val
ref $val ne "CODE"
Truth table0%0/4
not(A && B) or C
A= defined $valB= ref $valC= ref $val ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | if not defined($val) or not ref($val) or ref($val) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } elsif ( not exists $self->{defaults}->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # update $attr for eventual reconnects | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 8 | $conninfo->[3]->{$key} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 17 | return $self-> super( $key, $val); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||