| 1 | package Net::Async::Ping::TCP; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::Async::Ping::TCP::VERSION = '0.001001'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings NONFATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Future; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use POSIX 'ECONNREFUSED'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | has default_timeout => ( | |||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||
| 14 | default => 5, | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | has service_check => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | has bind => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | has port_number => ( | |||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | default => 7, | ||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub ping { | ||||||||||||||||||||||||||||
| 27 | 2 | ▶ | my ($self, $loop, $host, $timeout) = @_; | ||||||||||||||||||||||||||
|
Subroutine
ping: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $timeout ||= $self->default_timeout; | ||||||||||||||||||||||||||
|
Condition33%1/3
$timeout ||= $self->default_timeout
MC/DC0%0/2
$timeout ||= $self->default_timeout
$timeout
$self->default_timeout
Truth table33%1/3
A ||= B
A= $timeoutB= $self->default_timeout
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | my $service_check = $self->service_check; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | my $t0 = [Time::HiRes::gettimeofday]; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | return Future->wait_any( | ||||||||||||||||||||||||||||
| 35 | $loop->connect( | ||||||||||||||||||||||||||||
| 36 | host => $host, | ||||||||||||||||||||||||||||
| 37 | service => $self->port_number, | ||||||||||||||||||||||||||||
| 38 | socktype => 'stream', | ||||||||||||||||||||||||||||
| 39 | ($self->bind ? ( | ||||||||||||||||||||||||||||
| 40 | local_host => $self->bind, | ||||||||||||||||||||||||||||
| 41 | ) : ()), | ||||||||||||||||||||||||||||
| 42 | ), | ||||||||||||||||||||||||||||
| 43 | $loop->timeout_future(after => $timeout) | ||||||||||||||||||||||||||||
| 44 | ) | ||||||||||||||||||||||||||||
| 45 | ->then( | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub { Future->done(Time::HiRes::tv_interval($t0)) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 47 | sub { | ||||||||||||||||||||||||||||
| 48 | 2 | ▶ | my ($human, $layer) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||
| 49 | 2 | my $ex = pop; | |||||||||||||||||||||||||||
| 50 | 2 | ▶ | if ($layer && $layer eq 'connect') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$layer and $layer eq "connect"
MC/DC50%1/2
$layer and $layer eq "connect"
$layer
$layer eq "connect"
Truth table66%2/3
A and B
A= $layerB= $layer eq "connect"
| |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | return Future->done(Time::HiRes::tv_interval($t0)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $service_check and $ex == 111
MC/DC0%0/2
not $service_check and $ex == 111
not $service_check
$ex == 111
Truth table33%1/3
not(A) and B
A= not $service_checkB= $ex == 111
| |||||||||||||||||||||||||||||
| 52 | if !$service_check && $ex == ECONNREFUSED; | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 1 | Future->fail(Time::HiRes::tv_interval($t0)) | |||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||
| 56 | ) | ||||||||||||||||||||||||||||
| 57 | 2 | ▶ | } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||