| 1 | package Punk::Observe::Ingest; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 19 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 19 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 19 | ▶ | use Punk::Observe (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 19 | ▶ | use File::Raw::JSON (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 19 | our $VERSION = $Punk::Observe::VERSION; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 19 | our $MAX_RATIO = 20; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub _inflate { | ||||||||||||||||||||||||||
|
Subroutine
_inflate: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 16 | 0 | my ($buf, $how, $max) = @_; | |||||||||||||||||||||||||||
| 17 | 0 | ▶ | my $class = $how eq 'gzip' ? 'IO::Uncompress::Gunzip' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | : 'IO::Uncompress::Inflate'; | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | eval "require $class; 1" or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $z = $class->new(\$buf, Transparent => 0) or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | my $out = ''; | |||||||||||||||||||||||||||
| 23 | 0 | my $chunk; | |||||||||||||||||||||||||||
| 24 | 0 | while (1) { | |||||||||||||||||||||||||||
| 25 | 0 | my $n = $z->read($chunk, 65536); | |||||||||||||||||||||||||||
| 26 | # A negative read is a stream error, and the commonest one is a body | ||||||||||||||||||||||||||||
| 27 | # that stops part way through. Returning what arrived so far would | ||||||||||||||||||||||||||||
| 28 | # make the C build and this one disagree, and would surface later as | ||||||||||||||||||||||||||||
| 29 | # a malformed OTLP payload with the real cause thrown away. | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return undef if !defined $n || $n < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $n or $n < 0
MC/DC0%0/2
not defined $n or $n < 0
not defined $n
$n < 0
Truth table0%0/3
not(A) or B
A= not defined $nB= $n < 0
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | last if $n == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | $out .= $chunk; | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | return undef if length($out) > $max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return undef if $z->error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | close $z; | |||||||||||||||||||||||||||
| 37 | 0 | return $out; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 19 | 1; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||