| 1 | package IPC::MPS::Event; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | our @EXPORT = qw(spawn receive msg snd quit wt snd_wt listener open_node vpid2pid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.19'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Event; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Storable qw(freeze thaw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | my $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | $DEBUG and require Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | my @spawn = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | my %msg = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | my %fh2vpid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my %vpid2fh = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my %fh2fh = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $self_vpid = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $self_parent_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $self_parent_vpid = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | my $self_parent_closed = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | my %listener = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | my %node = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my %snd = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $ipc_loop = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my %vpid2pid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub vpid2pid { my ($vpid) = @_; $vpid2pid{$vpid} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vpid2pid: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my @rcv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my %r_bufs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my %w_bufs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my %pack = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | my %unpack = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | my %closed = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | my %fh2ww = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | my ($waited_vpid, $waited_msg, @waited_rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | my $blksize = 1024 * 16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | END { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | $ipc_loop or @spawn and carp "Probably have forgotten to call receive."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=4 SCAR=19.1
Branch: 1 branch
Condition20%1/5
$ipc_loop || @spawn && carp('Probably have forgotten to call receive.')
@spawn and carp("Probably have forgotten to call receive.")
MC/DC0%0/3
$ipc_loop || @spawn && carp('Probably have forgotten to call receive.')
$ipc_loop
@spawn
carp("Probably have forgotten to call receive.")
Truth table0%0/4
A || B and C
A= $ipc_loopB= @spawnC= carp("Probably have forgotten to call receive.")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | close $_ foreach values %fh2fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | sub spawn(&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | my ($spawn) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | socketpair(my $child, my $parent, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | my $vpid = refaddr $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | push @spawn, [$vpid, $child, $parent, $spawn]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | return $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | sub msg($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | ▶ | my ($msg, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | $msg{$msg} = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | sub snd($$;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 9 | ▶ | my ($vpid, $msg, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snd: called CC=7 SCAR=20.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 9 | ▶ | defined $vpid or carp("Argument vpid required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | ▶ | defined $msg or carp("Argument msg required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 9 | ▶ | $vpid = $self_parent_vpid if $vpid == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | $DEBUG and print "Send message '$msg' from $self_vpid to $vpid vpid in $self_vpid (\$\$=$$) with args: ", join(", ", @args), ".\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 9 | push @{$snd{$vpid}}, [$self_vpid, $vpid, $msg, \@args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 9 | ▶ | $closed{$vpid} = 1 if $msg eq "close" or $msg eq "exit"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msg eq "close" or $msg eq "exit"
MC/DC0%0/2
$msg eq "close" or $msg eq "exit"
$msg eq "close"
$msg eq "exit"
Truth table33%1/3
A or B
A= $msg eq "close"B= $msg eq "exit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 9 | w_event_cb_reg($vpid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub quit() { Event::unloop } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quit: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub snd_wt($$;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | my ($vpid, $msg, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snd_wt: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | defined $vpid or carp("Argument vpid required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | defined $msg or carp("Argument msg required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | snd($vpid, $msg, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | wt($vpid, $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | sub listener($$;%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my ($host, $port, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listener: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | defined $host or carp("Argument host required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | defined $port or carp("Argument port required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $sock = IO::Socket::INET->new(Proto => 'tcp', Blocking => 0, LocalHost => $host, LocalPort => $port, Listen => 20, ReuseAddr => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ($sock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | _pack_unpack($sock, %args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $listener{$sock} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | Event->io(fd => $sock, poll => "r", cb => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my ($event) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $fh = $event->w->fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $DEBUG > 1 and print "Read event for listener from $self_vpid: \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $sock = $fh->accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $pack{$sock} = $pack{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $unpack{$sock} = $unpack{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $sock->sockopt(SO_KEEPALIVE, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $vpid = refaddr $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $node{$sock} = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $fh2vpid{$sock} = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $vpid2fh{$vpid} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $fh2fh{$sock} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | Event->io(fd => $sock, poll => "r", cb => \&r_event_cb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | carp "Cannot open socket '$host:$port' in $self_vpid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | sub open_node($$;%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my ($host, $port, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_node: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | defined $host or carp("Argument host required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | defined $port or carp("Argument port required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $sock = IO::Socket::INET->new(Proto => 'tcp', Blocking => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $addr = sockaddr_in($port,inet_aton($host)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $sock->sockopt(SO_KEEPALIVE, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $rv = $sock->connect($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($rv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | _pack_unpack($sock, %args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $vpid = refaddr $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $node{$sock} = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $fh2vpid{$sock} = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $vpid2fh{$vpid} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $fh2fh{$sock} = $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | Event->io(fd => $sock, poll => "r", cb => \&r_event_cb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | carp "Cannot connect to socket '$host:$port' in $self_vpid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | sub _pack_unpack($%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my ($fh, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pack_unpack: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if (my $pack = $args{pack} and my $unpack = $args{unpack}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
my $pack = $args{"pack"} and my $unpack = $args{"unpack"}
MC/DC0%0/2
my $pack = $args{"pack"} and my $unpack = $args{"unpack"}
my $pack = $args{"pack"}
my $unpack = $args{"unpack"}
Truth table0%0/3
A and B
A= my $pack = $args{"pack"}B= my $unpack = $args{"unpack"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $r = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $r = $unpack->($pack->({a => ["b"]})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (ref $r eq "HASH" and ref $$r{a} eq "ARRAY" and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $r eq "HASH" and ref $r->{"a"} eq "ARRAY" and $r->{"a"}[0] and $r->{"a"}[0] eq "b"
ref $r eq "HASH" and ref $r->{"a"} eq "ARRAY" and $r->{"a"}[0]
ref $r eq "HASH" and ref $r->{"a"} eq "ARRAY"
MC/DC0%0/4
ref $r eq "HASH" and ref $r->{"a"} eq "ARRAY" and $r->{"a"}[0] and $r->{"a"}[0] eq "b"
ref $r eq "HASH"
ref $r->{"a"} eq "ARRAY"
$r->{"a"}[0]
$r->{"a"}[0] eq "b"
Truth table0%0/5
A and B and C and D
A= ref $r eq "HASH"B= ref $r->{"a"} eq "ARRAY"C= $r->{"a"}[0]D= $r->{"a"}[0] eq "b"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $$r{a}[0] and $$r{a}[0] eq "b") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (not $r or $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $r or $@
MC/DC0%0/2
not $r or $@
not $r
$@
Truth table0%0/3
not(A) or B
A= not $rB= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | carp "False pack unpack test"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $pack{$fh} = $pack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $unpack{$fh} = $unpack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ▶ | } elsif ($args{pack} or $args{unpack}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"pack"} or $args{"unpack"}
MC/DC0%0/2
$args{"pack"} or $args{"unpack"}
$args{"pack"}
$args{"unpack"}
Truth table0%0/3
A or B
A= $args{"pack"}B= $args{"unpack"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | carp "pack and unpack is pair options"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | sub receive(&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | ▶ | my ($receive) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
receive: called CC=11 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | $DEBUG > 1 and print "Call receive in $self_vpid (\$\$=$$)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | local $SIG{CHLD} = "IGNORE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | local $SIG{PIPE} = "IGNORE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | foreach (@spawn) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | my ($vpid, $child, $parent, $spawn) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | my $kid_pid = fork; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | defined $kid_pid or die "Can't fork: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | unless ($kid_pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | foreach (@spawn) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | close $$_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | close $$_[2] if $$_[2] ne $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | close $_ foreach values %fh2fh, values %listener; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $_->cancel foreach Event::all_watchers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | @spawn = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | %listener = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | %node = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | %msg = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | %fh2vpid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | %vpid2fh = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | %fh2fh = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | %snd = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | %vpid2pid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | $ipc_loop = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | @rcv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | %r_bufs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | %w_bufs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | %pack = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | %unpack = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | %closed = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | %fh2ww = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | ($waited_vpid, $waited_msg, @waited_rv) = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | $self_parent_fh = $parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | $self_parent_vpid = $self_vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | $self_vpid = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $fh2vpid{$self_parent_fh} = $self_parent_vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | $vpid2fh{$self_parent_vpid} = $self_parent_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | $fh2fh{$self_parent_fh} = $self_parent_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | Event->io(fd => $self_parent_fh, poll => "r", cb => \&r_event_cb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | $spawn->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | $vpid2pid{$vpid} = $kid_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | foreach (@spawn) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | my ($vpid, $child, $parent, $spawn, $receive) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | close $parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | $fh2vpid{$child} = $vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | $vpid2fh{$vpid} = $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | $fh2fh{$child} = $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | Event->io(fd => $child, poll => "r", cb => \&r_event_cb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | @spawn = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | $receive->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | ▶ | unless ($ipc_loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | $ipc_loop = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | Event::loop(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $ipc_loop = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | sub wt($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | ($waited_vpid, $waited_msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wt: called CC=10 SCAR=31.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | ▶ | defined $waited_vpid or carp("Argument vpid required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | ▶ | defined $waited_msg or carp("Argument msg required"), return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | $waited_vpid = $self_parent_vpid if $waited_vpid == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | foreach my $i (0 .. $#rcv) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my ($from, $msg, $args)= @{$rcv[$i]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ($from eq $waited_vpid and $msg eq $waited_msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$from eq $waited_vpid and $msg eq $waited_msg
MC/DC0%0/2
$from eq $waited_vpid and $msg eq $waited_msg
$from eq $waited_vpid
$msg eq $waited_msg
Truth table0%0/3
A and B
A= $from eq $waited_vpidB= $msg eq $waited_msg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | splice @rcv, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | return wantarray ? @$args : $$args[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | ▶ | $DEBUG and print "Start waiting for '$waited_vpid -> $waited_msg' in $self_vpid (\$\$=$$)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | Event::loop(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | my @rv = @waited_rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ($waited_vpid, $waited_msg, @waited_rv) = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | return wantarray ? @rv : $rv[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub w_event_cb_reg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 26 | ▶ | my ($to_vpid) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
w_event_cb_reg: called CC=13 SCAR=32.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 26 | ▶ | foreach my $to (defined $to_vpid ? $to_vpid : keys %snd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 25 | ▶ | if (@{$snd{$to}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 10 | my $fh = $vpid2fh{$to}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 10 | ▶ | unless ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if (@spawn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | carp "Probably have forgotten to call receive." if not defined $to_vpid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ($self_parent_fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | unless ($self_parent_closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $fh = $self_parent_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | carp "The addressee $to is unknown or has left in $self_vpid (\$\$=$$)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 8 | ▶ | unless (exists $w_bufs{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 8 | my $packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 8 | ▶ | if (my $pack = $pack{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $packet = $pack->(shift @{$snd{$to}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 8 | $packet = freeze shift @{$snd{$to}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | my $buf = join "", pack("N", length $packet), $packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 8 | $w_bufs{$fh} = $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | $DEBUG and (@{$snd{$to}} or delete $snd{$to}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$DEBUG && (@{$snd{$to};} || delete $snd{$to})
@{$snd{$to};} or delete $snd{$to}
MC/DC0%0/3
$DEBUG && (@{$snd{$to};} || delete $snd{$to})
$DEBUG
@{$snd{$to};}
delete $snd{$to}
Truth table0%0/4
A && B or C
A= $DEBUGB= @{$snd{$to};}C= delete $snd{$to}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 8 | $fh2ww{$fh} = Event->io(fd => $fh, poll => "w", cb => \&w_event_cb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | sub r_event_cb { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 9 | ▶ | my ($event) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
r_event_cb: called CC=43 SCAR=52.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 9 | my $fh = $event->w->fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 9 | ▶ | $DEBUG > 1 and print "Read event from $self_vpid: \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 9 | my $len = sysread $fh, (my $_buf), $blksize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 9 | ▶ | if ($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 8 | $r_bufs{$fh} .= $_buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | NEXT_MSG: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 8 | my $buf = $r_bufs{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 8 | ▶ | if (length $buf >= 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 8 | my $packet_length = unpack "N", substr $buf, 0, 4, ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 8 | ▶ | if (length $buf >= $packet_length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 8 | my $packet = substr $buf, 0, $packet_length, ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 8 | ▶ | $r_bufs{$fh} = $buf || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$buf || ''
MC/DC0%0/1
$buf || ''
$buf
Truth table50%1/2
A
A= $buf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 8 | ▶ | $DEBUG and ($r_bufs{$fh} or delete $r_bufs{$fh}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$DEBUG && ($r_bufs{$fh} || delete $r_bufs{$fh})
$r_bufs{$fh} or delete $r_bufs{$fh}
MC/DC0%0/3
$DEBUG && ($r_bufs{$fh} || delete $r_bufs{$fh})
$DEBUG
$r_bufs{$fh}
delete $r_bufs{$fh}
Truth table0%0/4
A && B or C
A= $DEBUGB= $r_bufs{$fh}C= delete $r_bufs{$fh}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 8 | my ($from, $to, $msg, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 8 | ▶ | if (my $unpack = $unpack{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ($from, $to, $msg, $args) = @{$unpack->($packet)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 8 | ($from, $to, $msg, $args) = @{thaw $packet}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 8 | ▶ | if ($node{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $from = $node{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $to = $self_vpid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | ▶ | $DEBUG and print "Got message '$msg' from $from to $to vpid in $self_vpid (\$\$=$$) with args: ", join(", ", @$args), ".\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 8 | ▶ | if ($to == $self_vpid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 8 | ▶ | $DEBUG and print "Run message sub '$msg' from $from to $to vpid in $self_vpid (\$\$=$$) with args: ", join(", ", @$args), ".\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 8 | ▶ | if (defined $waited_vpid and defined $waited_msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $waited_vpid and defined $waited_msg
MC/DC50%1/2
defined $waited_vpid and defined $waited_msg
defined $waited_vpid
defined $waited_msg
Truth table66%2/3
A and B
A= defined $waited_vpidB= defined $waited_msg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | push @rcv, [$from, $msg, $args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 7 | ▶ | if ($msg{$msg}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 7 | push @rcv, [$from, $msg, $args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | $DEBUG and print "Unknown message '$msg'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } elsif ($vpid2fh{$to}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | $DEBUG and print "Remittance message '$msg' from $from to $to vpid in $self_vpid (\$\$=$$) with args: ", join(", ", @$args), ".\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | push @{$snd{$to}}, [$from, $to, $msg, $args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | carp "Got Wandered message '$msg' from $from to $to in $self_vpid (\$\$=$$)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | ▶ | redo NEXT_MSG if $r_bufs{$fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } elsif (defined $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | ▶ | if (exists $fh2ww{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $fh2ww{$fh}->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | delete $fh2ww{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | $event->w->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | my $vpid = delete $fh2vpid{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | delete $vpid2fh{$vpid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | delete $r_bufs{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | delete $w_bufs{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | delete $fh2fh{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | delete $vpid2pid{$vpid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | delete $pack{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | delete $unpack{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | if (my $node_vpid = $node{$fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | delete $node{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if ($msg{NODE_CLOSED}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $msg{NODE_CLOSED}->($node_vpid, $fh->connected ? 1 : 0) unless $closed{$vpid}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 1 | ▶ | if ($msg{SPAWN_CLOSED}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $msg{SPAWN_CLOSED}->($vpid) unless $closed{$vpid}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | delete $closed{$vpid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | if ($self_parent_fh and $self_parent_fh eq $fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self_parent_fh and $self_parent_fh eq $fh
MC/DC0%0/2
$self_parent_fh and $self_parent_fh eq $fh
$self_parent_fh
$self_parent_fh eq $fh
Truth table33%1/3
A and B
A= $self_parent_fhB= $self_parent_fh eq $fh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | $self_parent_closed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | ▶ | unless (defined $waited_vpid and defined $waited_msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $waited_vpid and defined $waited_msg
MC/DC0%0/2
defined $waited_vpid and defined $waited_msg
defined $waited_vpid
defined $waited_msg
Truth table33%1/3
A and B
A= defined $waited_vpidB= defined $waited_msg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | unless (@rcv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $DEBUG and die "Can't read '$fh': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 8 | ▶ | if (defined $waited_vpid and defined $waited_msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $waited_vpid and defined $waited_msg
MC/DC50%1/2
defined $waited_vpid and defined $waited_msg
defined $waited_vpid
defined $waited_msg
Truth table66%2/3
A and B
A= defined $waited_vpidB= defined $waited_msg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | foreach my $i (0 .. $#rcv) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | my ($from, $msg, $args)= @{$rcv[$i]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | ▶ | if ($msg eq $waited_msg and $from eq $waited_vpid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msg eq $waited_msg and $from eq $waited_vpid
MC/DC0%0/2
$msg eq $waited_msg and $from eq $waited_vpid
$msg eq $waited_msg
$from eq $waited_vpid
Truth table33%1/3
A and B
A= $msg eq $waited_msgB= $from eq $waited_vpid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | splice @rcv, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | ▶ | $DEBUG and print "Stop waiting for '$waited_vpid -> $waited_msg' in $self_vpid (\$\$=$$)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | @waited_rv = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | Event::unloop(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | unless (exists $vpid2fh{$waited_vpid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | Event::unloop(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 7 | ▶ | while (my $rcv = shift @rcv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 7 | my ($from, $msg, $args)= @{$rcv}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 7 | ▶ | $msg{$msg}->($from, @$args) unless $closed{$from}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 6 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | sub w_event_cb { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | ▶ | my ($event) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
w_event_cb: called CC=6 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 8 | my $fh = $event->w->fd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 8 | ▶ | $DEBUG > 1 and print "Write event from $self_vpid: \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 8 | ▶ | $fh2fh{$fh} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 8 | my $buf = $w_bufs{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 8 | my $len = syswrite $fh, $buf, $blksize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 8 | ▶ | if ($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 8 | substr $buf, 0, $len, ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 8 | ▶ | if (length $buf) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $w_bufs{$fh} = $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 8 | delete $w_bufs{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 8 | $event->w->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 8 | delete $fh2ww{$fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 8 | w_event_cb_reg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | $DEBUG and die "Can't write to '$fh': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||