Branch Coverage

blib/lib/Mail/SpamAssassin/AsyncLoop.pm
Criterion Covered Total %
branch 67 170 39.4


line true false branch
52 40 0 'Time::HiRes'->can('clock_getres') ? :
56 0 40 unless (eval { do { $timer_resolution = 'Time::HiRes'->can('clock_getres') ? &Time::HiRes::clock_getres(scalar Time::HiRes::CLOCK_REALTIME()) : 0.001; 1 } })
93 0 0 if ($domain =~ /\[/) { }
100 0 0 if $domain eq ''
102 0 0 $domain =~ /^ (?: [^.]* ) \. (.*) \z/sx ? :
104 0 0 if (@search_keys > 20)
179 0 13 unless defined $id and $id ne ''
180 0 13 unless $key
181 0 13 unless $ent->{'type'}
184 13 0 unless defined $ent->{'start_time'}
190 0 13 if (defined $zone and $conf_by_zone)
194 0 0 if (exists $conf_by_zone->{$zone}) { }
0 0 elsif ($zone eq '') { }
200 0 0 $zone =~ /^( (?: [^.] | \[ (?: \\. | [^\]\\] )* \] )* ) \. (.*) \z/sx ? :
206 0 13 if $settings
209 0 13 if $settings and not defined $t_init
210 13 0 unless defined $t_init
211 0 13 unless defined $t_init
214 0 13 if $settings and not defined $t_end
215 13 0 unless defined $t_end
216 13 0 unless defined $t_end
217 0 13 if $t_end < 0
218 0 13 if $t_init < $t_end
221 13 0 if (defined $master_deadline)
223 0 13 if $time_avail < 0.5
224 0 13 if ($t_init > $time_avail)
226 0 0 if $t_end > $time_avail
234 0 65 ref $ent->{$_} ? :
243 13 0 !$clipped_by_master_deadline ? :
260 0 135 unless $ent
265 0 135 unless exists $ent->{'type'}
266 0 135 unless $cb
273 122 13 if ($dns_query_info) { }
275 0 122 unless defined $id
277 0 122 unless lc $id_tail eq lc $dnskey
281 122 0 if (not $pkt) { }
290 0 0 if (not $cb) { }
297 0 0 unless (eval { do { &$cb($ent, $pkt); 1 } })
300 0 0 if $@ =~ /__alarm__ignore__\(.*\)/s
312 0 13 if ($dns_query_blockages)
316 0 0 if defined $blocked
319 0 13 if ($blocked) { }
327 0 13 if ($pkt_id ne $id)
336 135 0 if ($appl_cb)
339 0 135 !defined($appl_ent->{'rulename'}) ? :
343 0 135 unless (eval { do { &$appl_cb($appl_ent, $pkt); 1 } })
346 0 0 if $@ =~ /__alarm__ignore__\(.*\)/s
353 0 13 if not $cb_count
356 0 13 unless defined $id
423 1 0 if (defined $timeout and $timeout > 0 and %$pending and $self->{'total_queries_started'} > 0)
436 2 0 if not defined $max_deadline or $deadline > $max_deadline
439 1 0 if (defined $max_deadline)
441 0 1 if $timer_resolution == 1 and $max_deadline > int $max_deadline
444 0 1 if $sufficient_timeout < 0
445 0 1 if ($timeout > $sufficient_timeout)
458 5 3059 if (%$pending)
461 5 0 !$nfound ? :
473 13 4 if (exists $self->{'finished'}{$id})
476 0 13 unless defined $ent->{'finish_time'}
486 2 3062 if (%$pending)
489 1 1 !($allow_aborting_of_expired && $self->{'total_queries_started'}) ? :
496 0 4 if $timer_resolution == 1 and $dt > int $dt
497 4 0 if $now <= $ent->{'start_time'} + $dt
504 3062 2 if (not %$pending) { }
0 2 elsif ($allexpired and $allow_aborting_of_expired) { }
515 0 2 $allexpired ? :
521 0 3064 unless (eval { do { if (%$pending) { $self->{'last_poll_responses_time'} = $now; my $nfound = $self->{'main'}{'resolver'}->poll_responses($timeout); dbg('async: select found %s responses ready (t.o.=%.1f)', !$nfound ? 'no' : $nfound, $timeout); } ; $now = &Mail::SpamAssassin::AsyncLoop::time(); while (my($key, $ent) = each %$pending) { do { my $id = $ent->{'id'}; if (exists $self->{'finished'}{$id}) { delete $self->{'finished'}{$id}; $anydone = 1; $ent->{'finish_time'} = $now unless defined $ent->{'finish_time'}; my $elapsed = $ent->{'finish_time'} - $ent->{'start_time'}; dbg('async: completed in %.3f s: %s', $elapsed, $ent->{'display_id'}); $self->{'timing_by_query'}{". $key"} += $elapsed; ++$self->{'queries_completed'}; ++$self->{'total_queries_completed'}; delete $pending->{$key}; } }; } ; if (%$pending) { my $r = !($allow_aborting_of_expired && $self->{'total_queries_started'}) ? 1 : $self->{'total_queries_completed'} / $self->{'total_queries_started'}; my $r2 = $r * $r; while (my($key, $ent) = each %$pending) { do { ++$typecount{$ent->{'type'}}; my $t_init = $ent->{'timeout_initial'}; my $dt = $t_init - ($t_init - $ent->{'timeout_min'}) * $r2; $dt = 1 + int($dt) if $timer_resolution == 1 and $dt > int $dt; $allexpired = 0 if $now <= $ent->{'start_time'} + $dt }; } ; dbg('async: queries completed: %d, started: %d', $self->{'queries_completed'}, $self->{'queries_started'}); } ; if (not %$pending) { $alldone = 1; } elsif ($allexpired and $allow_aborting_of_expired) { dbg('async: escaping: lost or timed out requests or responses'); $self->abort_remaining_lookups; $alldone = 1; } else { dbg('async: queries active: %s%s at %s', join(' ', map({"$_=$typecount{$_}";} sort(keys %typecount))), $allexpired ? ', all expired' : '', scalar localtime &Mail::SpamAssassin::AsyncLoop::time()); $alldone = 0; } ; 1 } })
522 0 0 $@ ne '' ? :
524 0 0 if $eval_stat =~ /__alarm__ignore__\(.*\)/s
529 3064 0 wantarray ? :
553 0 0 defined $ent->{'timeout_initial'} && $now > $ent->{'start_time'} + $ent->{'timeout_initial'} ? :
556 0 0 unless defined $ent->{'finish_time'}
568 0 0 if ($cb)
570 0 0 !defined($ent->{'rulename'}) ? :
574 0 0 unless (eval { do { &$cb($ent, undef); 1 } })
577 0 0 if $@ =~ /__alarm__ignore__\(.*\)/s
582 0 0 unless $cb_count
587 0 96 if $foundcnt > 0
614 0 13 unless defined $timestamp
616 0 13 unless (defined $key)
618 0 0 if ($id eq $pending->{$id}{'id'}) { }
622 0 0 if ($id eq $pending->{$tkey}{'id'})
627 0 13 if (not defined $key) { }
632 0 13 if (not defined $ent_id) { }
0 13 elsif ($id ne $ent_id) { }