| 1 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package DR::Tnt::LowLevel::Connector::Sync; | ||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use IO::Socket::UNIX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | extends 'DR::Tnt::LowLevel::Connector'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub _connect { | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my ($self, $cb) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_connect: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my $fh; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | if ($self->host eq 'unix' or $self->host eq 'unix/') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->host eq "unix" or $self->host eq "unix/"
MC/DC0%0/2
$self->host eq "unix" or $self->host eq "unix/"
$self->host eq "unix"
$self->host eq "unix/"
Truth table0%0/3
A or B
A= $self->host eq "unix"B= $self->host eq "unix/"
| |||||||||||||||||||||||||||||
| 17 | 0 | $fh = IO::Socket::UNIX->new( | |||||||||||||||||||||||||||
| 18 | Type => SOCK_STREAM, | ||||||||||||||||||||||||||||
| 19 | Peer => $self->port, | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | } else { | ||||||||||||||||||||||||||||
| 22 | 0 | $fh = IO::Socket::INET->new( | |||||||||||||||||||||||||||
| 23 | PeerHost => $self->host, | ||||||||||||||||||||||||||||
| 24 | PeerPort => $self->port, | ||||||||||||||||||||||||||||
| 25 | Proto => 'tcp', | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | unless ($fh) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $cb->(ER_SOCKET => $!); | |||||||||||||||||||||||||||
| 31 | 0 | return; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | $self->_set_fh($fh); | |||||||||||||||||||||||||||
| 35 | 0 | $cb->(OK => 'Socket connected'); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub _handshake { | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my ($self, $cb) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_handshake: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 42 | $self->sread(128, sub { | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my ($state, $message, $hs) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | unless ($state eq 'OK') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | pop; | |||||||||||||||||||||||||||
| 46 | 0 | goto \&$cb; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 0 | $cb->(OK => 'handshake was read', $hs); | |||||||||||||||||||||||||||
| 49 | 0 | }); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub send_pkt { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my ($self, $pkt, $cb) = @_; | ||||||||||||||||||||||||||
|
Subroutine
send_pkt: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | while (1) { | |||||||||||||||||||||||||||
| 56 | 0 | my $done = syswrite $self->fh, $pkt; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | unless (defined $done) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | $cb->(ER_SOCKET => $!); | |||||||||||||||||||||||||||
| 59 | 0 | return; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($done == length $pkt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | $cb->(OK => 'swrite done'); | |||||||||||||||||||||||||||
| 63 | 0 | return; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | substr $pkt, 0, $done, '' if $done; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub _wait_something { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_wait_something: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return unless $self->fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | my $blob = ''; | |||||||||||||||||||||||||||
| 75 | 0 | my $done = sysread $self->fh, $blob, 4096; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | unless ($done) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | unless (defined $done) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->socket_error($! // 'Connection lost'); | ||||||||||||||||||||||||||
|
Condition0%0/2
$! // "Connection lost"
MC/DC0%0/1
$! // "Connection lost"
$!
Truth table0%0/2
A
A= $!
| |||||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 0 | $self->socket_error('Remote host closed connection'); | |||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | $self->rbuf($self->rbuf . $blob); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | } until $self->check_rbuf; | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | after handshake => sub { | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 92 | 0 | $self->_wait_something; | |||||||||||||||||||||||||||
| 93 | 3 | }; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | after wait_response => sub { | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 97 | 0 | $self->_wait_something; | |||||||||||||||||||||||||||
| 98 | 3 | }; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||