| 1 | package MR::IProto::Connection::Sync; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | MR::IProto::Connection::Sync - sync communication | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Used to perform synchronous communication. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | extends 'MR::IProto::Connection'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Errno; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Socket qw( TCP_NODELAY SO_KEEPALIVE SO_SNDTIMEO SO_RCVTIMEO ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | has _socket => ( | |||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||
| 22 | isa => 'IO::Socket::INET', | ||||||||||||||||||||||||||||
| 23 | predicate => '_has_socket', | ||||||||||||||||||||||||||||
| 24 | clearer => '_clear_socket', | ||||||||||||||||||||||||||||
| 25 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | has _sent => ( | ||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 31 | 1 | ); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | has last_sync => ( | |||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||
| 35 | isa => 'Int', | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | has last_error => ( | |||||||||||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||||||||||
| 40 | isa => 'Str', | ||||||||||||||||||||||||||||
| 41 | default => '', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 PUBLIC METHODS | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =over | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =item fh | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | Returns socket. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =item send | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | See L<MR::IProto::Connection/send> for more information. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub fh { return $_[0]->_has_socket && $_[0]->_socket } | ||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$_[0]->_has_socket && $_[0]->_socket
MC/DC0%0/2
$_[0]->_has_socket && $_[0]->_socket
$_[0]->_has_socket
$_[0]->_socket
Truth table0%0/3
A && B
A= $_[0]->_has_socketB= $_[0]->_socket
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub Close { | ||||||||||||||||||||||||||
|
Subroutine
Close: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $reason) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | $self->_handle_error(undef, undef, $reason); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub send { | ||||||||||||||||||||||||||
|
Subroutine
send: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | my ($self, $msg, $payload, $callback, $no_reply, $sync) = @_; | |||||||||||||||||||||||||||
| 67 | 0 | my $server = $self->server; | |||||||||||||||||||||||||||
| 68 | 0 | my $sent = $self->_sent; | |||||||||||||||||||||||||||
| 69 | 0 | my $ok = eval { | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | if(defined $sync) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | die "Sync $sync already sent" if exists $sent->{$sync}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | 1 while exists $sent->{$sync = $self->_choose_sync()}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | $server->_send_started($sync, $msg, $payload); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $socket = $self->_socket; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | unless (%$sent) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | vec((my $rin = ''), fileno($socket), 1) = 1; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if (select((my $rout = $rin), undef, undef, 0) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (sysread($socket, my $buf, 1)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | die "More then 0 bytes was received when nothing was waited for"; | |||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||
| 84 | # Connection was closed by other side, socket is in CLOSE_WAIT state, reconnecting | ||||||||||||||||||||||||||||
| 85 | 0 | $self->_clear_socket(); | |||||||||||||||||||||||||||
| 86 | 0 | $socket = $self->_socket; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | my $header = $self->_pack_header($msg, length $payload, $sync); | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | if( $server->debug >= 5 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | $server->_debug_dump('send header: ', $header); | |||||||||||||||||||||||||||
| 94 | 0 | $server->_debug_dump('send payload: ', $payload); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my $write = $header . $payload; | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | while( length $write ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | my $written = syswrite($socket, $write); | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (!defined $written) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($! != Errno::EINTR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $! = Errno::ETIMEDOUT if $! == Errno::EAGAIN; # Hack over SO_SNDTIMEO behaviour | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | die "send: $!"; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||
| 106 | 0 | substr $write, 0, $written, ''; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 0 | 1; | |||||||||||||||||||||||||||
| 110 | }; | ||||||||||||||||||||||||||||
| 111 | 0 | my $err = $@; | |||||||||||||||||||||||||||
| 112 | 0 | $self->last_sync($sync); | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | if($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ($no_reply) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | $callback->(undef, undef); | |||||||||||||||||||||||||||
| 116 | 0 | $server->_recv_finished($sync, undef, undef); | |||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||
| 118 | 0 | $sent->{$sync} = $callback; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | else { | ||||||||||||||||||||||||||||
| 122 | 0 | $self->_handle_error($sync, $callback, $err); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 0 | return $ok; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub recv_all { | ||||||||||||||||||||||||||
|
Subroutine
recv_all: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||
| 129 | 0 | my $server = $self->server; | |||||||||||||||||||||||||||
| 130 | 0 | my $sent = $self->_sent; | |||||||||||||||||||||||||||
| 131 | 0 | my $dump_resp = $server->debug >= 6; | |||||||||||||||||||||||||||
| 132 | 0 | my @sync = keys %$sent; | |||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $n = $opts{max} || @sync; | ||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'max'} || @sync
MC/DC0%0/2
$opts{'max'} || @sync
$opts{'max'}
@sync
Truth table0%0/3
A || B
A= $opts{'max'}B= @sync
| |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | while ($n-- and %$sent) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n-- and %$sent
MC/DC0%0/2
$n-- and %$sent
$n--
%$sent
Truth table0%0/3
A and B
A= $n--B= %$sent
| |||||||||||||||||||||||||||||
| 135 | 0 | my ($resp_msg, $resp_payload); | |||||||||||||||||||||||||||
| 136 | 0 | my ($sync,$callback); | |||||||||||||||||||||||||||
| 137 | 0 | my $ok = eval { | |||||||||||||||||||||||||||
| 138 | 0 | my $socket = $self->_socket; | |||||||||||||||||||||||||||
| 139 | 0 | my $resp_header; | |||||||||||||||||||||||||||
| 140 | 0 | my $to_read = 12; | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | while( $to_read ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | my $read = sysread($socket, my $buf, $to_read); | |||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (!defined $read) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($! != Errno::EINTR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $! = Errno::ETIMEDOUT if $! == Errno::EAGAIN; # Hack over SO_RCVTIMEO behaviour | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | die "recv: $!"; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | } elsif ($read == 0) { | ||||||||||||||||||||||||||||
| 149 | 0 | die "recv: Unexpected end-of-file"; | |||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||
| 151 | 0 | $resp_header .= $buf; | |||||||||||||||||||||||||||
| 152 | 0 | $to_read -= $read; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $server->_debug_dump('recv header: ', $resp_header) if $dump_resp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | ($resp_msg, my $resp_length, $sync) = $self->_unpack_header($resp_header); | |||||||||||||||||||||||||||
| 157 | 0 | ▶ | $callback = delete $sent->{$sync} or die "Reply sync $sync not found"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | #die "Request and reply sync is different: $resp_sync != $sync" unless $resp_sync == $sync; | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | $to_read = $resp_length; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | while( $to_read ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | my $read = sysread($socket, my $buf, $to_read); | |||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (!defined $read) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ($! != Errno::EINTR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $! = Errno::ETIMEDOUT if $! == Errno::EAGAIN; # Hack over SO_RCVTIMEO behaviour | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | die "recv: $!"; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } elsif ($read == 0) { | ||||||||||||||||||||||||||||
| 169 | 0 | die "recv: Unexpected end-of-file"; | |||||||||||||||||||||||||||
| 170 | } else { | ||||||||||||||||||||||||||||
| 171 | 0 | $resp_payload .= $buf; | |||||||||||||||||||||||||||
| 172 | 0 | $to_read -= $read; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $server->_debug_dump('recv payload: ', $resp_payload) if $dump_resp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 0 | 1; | |||||||||||||||||||||||||||
| 177 | }; | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | $server->_recv_finished($sync, $resp_msg, $resp_payload); | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | die "No Callback" unless $callback; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | $callback->($resp_msg, $resp_payload); | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||
| 184 | 0 | $self->_handle_error(undef, undef, $@); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | 0 | return; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | =item set_timeout( $timeout ) | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | Set timeout value for existing connection. | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | =cut | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub set_timeout { | ||||||||||||||||||||||||||
|
Subroutine
set_timeout: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 197 | 0 | my ($self, $timeout) = @_; | |||||||||||||||||||||||||||
| 198 | 0 | ▶ | $self->_set_timeout($self->_socket, $timeout) if $self->_has_socket(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | return; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =back | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =cut | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub _build__socket { | ||||||||||||||||||||||||||
|
Subroutine
_build__socket: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 207 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 208 | 0 | my $server = $self->server; | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | $server->_debug("connecting") if $server->debug >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | my $socket = IO::Socket::INET->new( | ||||||||||||||||||||||||||||
| 211 | PeerHost => $self->host, | ||||||||||||||||||||||||||||
| 212 | PeerPort => $self->port, | ||||||||||||||||||||||||||||
| 213 | Proto => 'tcp', | ||||||||||||||||||||||||||||
| 214 | Timeout => $self->connect_timeout, | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | ) or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | $@ =~ s/^IO::Socket::INET: (?:connect: )?//; | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($@ eq 'timeout') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | # Hack over IO::Socket behaviour | ||||||||||||||||||||||||||||
| 219 | 0 | $! = Errno::ETIMEDOUT; | |||||||||||||||||||||||||||
| 220 | 0 | $@ = "$!"; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | 0 | die "connect: $@"; | |||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $socket->sockopt(SO_KEEPALIVE, 1) if $self->tcp_keepalive; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $socket->setsockopt((getprotobyname('tcp'))[2], TCP_NODELAY, 1) if $self->tcp_nodelay; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->_set_timeout($socket, $self->timeout) if $self->timeout; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $server->_debug("connected") if $server->debug >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | return $socket; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub _set_timeout { | ||||||||||||||||||||||||||
|
Subroutine
_set_timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 232 | 0 | my ($self, $socket, $timeout) = @_; | |||||||||||||||||||||||||||
| 233 | 0 | my $sec = int $timeout; # seconds | |||||||||||||||||||||||||||
| 234 | 0 | my $usec = int( ($timeout - $sec) * 1_000_000 ); # micro-seconds | |||||||||||||||||||||||||||
| 235 | 0 | my $timeval = pack "L!L!", $sec, $usec; # struct timeval; | |||||||||||||||||||||||||||
| 236 | 0 | $socket->sockopt(SO_SNDTIMEO, $timeval); | |||||||||||||||||||||||||||
| 237 | 0 | $socket->sockopt(SO_RCVTIMEO, $timeval); | |||||||||||||||||||||||||||
| 238 | 0 | return; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub _handle_error { | ||||||||||||||||||||||||||
|
Subroutine
_handle_error: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 242 | 0 | my ($self, $sync, $callback, $error) = @_; | |||||||||||||||||||||||||||
| 243 | 0 | my $errno = $!; | |||||||||||||||||||||||||||
| 244 | 0 | ▶ | if (!$error) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 245 | 0 | $error = 'Unknown error'; | |||||||||||||||||||||||||||
| 246 | } elsif ($error =~ /^(.+?) at \S+ line \d+/s) { | ||||||||||||||||||||||||||||
| 247 | 0 | $error = $1; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | $self->last_error($error); | |||||||||||||||||||||||||||
| 250 | 0 | my $server = $self->server; | |||||||||||||||||||||||||||
| 251 | 0 | $server->_debug("error: $error"); | |||||||||||||||||||||||||||
| 252 | 0 | ▶ | if($self->_has_socket()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | close($self->_socket); | |||||||||||||||||||||||||||
| 254 | 0 | $self->_clear_socket(); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | $server->active(0); | |||||||||||||||||||||||||||
| 257 | 0 | my $sent = $self->_sent; | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | if($sync && $callback) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sync and $callback
MC/DC0%0/2
$sync and $callback
$sync
$callback
Truth table0%0/3
A and B
A= $syncB= $callback
| |||||||||||||||||||||||||||||
| 259 | 0 | $server->_recv_finished($sync, undef, undef, $error, $errno); | |||||||||||||||||||||||||||
| 260 | 0 | $callback->(undef, undef, $error, $errno); | |||||||||||||||||||||||||||
| 261 | 0 | delete $sent->{$sync}; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | 0 | foreach my $sync (keys %$sent) { | |||||||||||||||||||||||||||
| 264 | 0 | $server->_recv_finished($sync, undef, undef, $error, $errno); | |||||||||||||||||||||||||||
| 265 | 0 | $sent->{$sync}->(undef, undef, $error, $errno); | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | 0 | undef %$sent; | |||||||||||||||||||||||||||
| 268 | 0 | return; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | L<MR::IProto::Connection>, L<MR::IProto::Cluster::Server>. | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =cut | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 1 | ▶ | no Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 278 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 1 | 1; | |||||||||||||||||||||||||||