blib/lib/IPC/Messaging.pm

filter: Statementstmt 44.7% 178 / 398 Branchbran 25.0% 47 / 188 Conditioncond 8.7% 8 / 91 MC/DCmcdc 0.0% 0 / 51 Subroutinesub 62.3% 38 / 61 Podpod 0.0% 0 / 20 totaltotal 33.5% 271 / 809 CC 131 SCAR 55.8
CC
131
Cov
34%
pickup_one_message
1122.0
run_queue
506.0
receive_once
90.0
CRAP 265.2
↑ Summary
1 package IPC::Messaging;
2 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 require Exporter;
6 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use vars qw(@EXPORT $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use B::Generate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use IO::Socket::UNIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Socket qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Module::Load::Conditional "can_load";
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use POSIX ":sys_wait_h";
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 $VERSION = '0.01_14';
19 sub spawn (&);
20 sub receive (&);
21 sub receive_loop (&);
22 sub got;
23 sub then (&);
24 sub after ($$);
25  
26 2 @EXPORT = qw(spawn receive receive_loop got then after);
27  
28 2 my $MAX_DGRAM_SIZE = 16384;
29 2 my $TCP_READ_SIZE = 65536;
30 2 my $secret;
31 my $root;
32 2 my $messaging_dir;
33 2 my $i_am_root;
34 2 my $my_sock;
35 2 my $my_sock_fileno;
36 2 my %their_sock;
37 2 my @msg_queue;
38 2 my @processes_to_reap;
39 2 my $recv;
40 2 my %read_socks;
41 2 my %write_socks;
42 2 my ($use_kqueue, $use_epoll, $use_select);
43 2 my $kq;
44 2 my $epfd;
45  
46 sub debug
47 0 ▶{
Subroutine debug: not called CC=1 SCAR=0.0
Pod undocumented
48 # print STDERR @_;
49 }
50  
51 sub spawn (&)
52 0 ▶{
Subroutine spawn: not called CC=3 SCAR=24.8
Pod undocumented
53 0 my ($psub) = @_;
54 0 my $pid = CORE::fork;
55 0 ▶ die "unable to fork: $!" unless defined $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pid 0 0 0
56 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 0 0 0
57 # parent
58 0 my $child = IPC::Messaging::Process->_new($pid);
59 0 ▶ receive {
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ got [_READY => $child] => then {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ after 5 => then { die "child $pid not ready" };
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 };
63 0 return $child;
64 } else {
65 # child
66 0 $i_am_root = 0;
67 0 initpid();
68 0 my $parent = IPC::Messaging::Process->_new(getppid);
69 0 $parent->_READY;
70 0 $psub->();
71 0 exit 0;
72 }
73 }
74  
75 sub END
76 2 ▶{
Subroutine END: called CC=7 SCAR=31.7
77 2 ▶ if ($messaging_dir && $i_am_root && -e $messaging_dir && !-l $messaging_dir) {
Branch: 2 branches
BranchTrueFalseTotal
if ($messaging_dir and $i_am_root and -e $messaging_dir and not -l $messaging_dir) { } 2 0 2
elsif ($messaging_dir and not $i_am_root) { } 0 0 0
Condition33%3/9
$messaging_dir and $i_am_root and -e $messaging_dir and not -l $messaging_dir
!ll&&!rl&&r
002
$messaging_dir and $i_am_root and -e $messaging_dir
!ll&&!rl&&r
002
$messaging_dir and $i_am_root
!ll&&!rl&&r
002
MC/DC0%0/4
$messaging_dir and $i_am_root and -e $messaging_dir and not -l $messaging_dir
$messaging_dir $i_am_root -e $messaging_dir not -l $messaging_dir
Truth table20%1/5
A and B and C and not(D)
A= $messaging_dirB= $i_am_rootC= -e $messaging_dirD= not -l $messaging_dir
ABCDresult
0XXX0
10XX0
110X0
11100
11111
78 # system("ls -l $messaging_dir");
79 2 system("rm -rf $messaging_dir");
80 ▶ } elsif ($messaging_dir && !$i_am_root) {
Condition0%0/3
$messaging_dir and not $i_am_root
!ll&&!rl&&r
000
MC/DC0%0/2
$messaging_dir and not $i_am_root
$messaging_dir not $i_am_root
Truth table0%0/3
A and not(B)
A= $messaging_dirB= not $i_am_root
ABresult
0X0
100
111
81 0 my $parent = IPC::Messaging::Process->_new(getppid);
82 0 $parent->EXIT;
83 }
84 }
85  
86 sub run_queue
87 0 ▶{
Subroutine run_queue: not called CC=22 SCAR=62.3
Pod undocumented
88 0 my ($r) = @_;
89 0 ▶ return unless @{$r->{pats}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$r->{"pats"};} 0 0 0
90 0 ▶ for (my $i = 0; $i < @msg_queue; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @msg_queue) 0 0 0
91 0 my $m = $msg_queue[$i];
92 0 for my $pat (@{$r->{pats}}) {
93 0 ▶ if ($pat->{name} ne $m->{m} && $pat->{name} ne "_") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat->{"name"} ne $m->{"m"} and $pat->{"name"} ne "_") 0 0 0
Condition0%0/3
$pat->{"name"} ne $m->{"m"} and $pat->{"name"} ne "_"
!ll&&!rl&&r
000
MC/DC0%0/2
$pat->{"name"} ne $m->{"m"} and $pat->{"name"} ne "_"
$pat->{"name"} ne $m->{"m"} $pat->{"name"} ne "_"
Truth table0%0/3
A and B
A= $pat->{"name"} ne $m->{"m"}B= $pat->{"name"} ne "_"
ABresult
0X0
100
111
94 # does not match if message name is different
95 0 next;
96 }
97 0 ▶ if ($pat->{proc} && $m->{f} && $m->{f} != $pat->{proc}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat->{"proc"} and $m->{"f"} and $m->{"f"} != $pat->{"proc"}) 0 0 0
Condition0%0/6
$pat->{"proc"} and $m->{"f"} and $m->{"f"} != $pat->{"proc"}
!ll&&!rl&&r
000
$pat->{"proc"} and $m->{"f"}
!ll&&!rl&&r
000
MC/DC0%0/3
$pat->{"proc"} and $m->{"f"} and $m->{"f"} != $pat->{"proc"}
$pat->{"proc"} $m->{"f"} $m->{"f"} != $pat->{"proc"}
Truth table0%0/4
A and B and C
A= $pat->{"proc"}B= $m->{"f"}C= $m->{"f"} != $pat->{"proc"}
ABCresult
0XX0
10X0
1100
1111
98 # does not match if sender process is different
99 0 next;
100 }
101 0 ▶ my $msock = $m->{fsock} || $m->{sock};
Condition0%0/3
$m->{'fsock'} || $m->{'sock'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$m->{'fsock'} || $m->{'sock'}
$m->{'fsock'} $m->{'sock'}
Truth table0%0/3
A || B
A= $m->{'fsock'}B= $m->{'sock'}
ABresult
1X1
011
000
102 0 ▶ if ($pat->{sock} && $msock && $msock->fileno != $pat->{sock}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat->{"sock"} and $msock and $msock->fileno != $pat->{"sock"}) 0 0 0
Condition0%0/6
$pat->{"sock"} and $msock and $msock->fileno != $pat->{"sock"}
!ll&&!rl&&r
000
$pat->{"sock"} and $msock
!ll&&!rl&&r
000
MC/DC0%0/3
$pat->{"sock"} and $msock and $msock->fileno != $pat->{"sock"}
$pat->{"sock"} $msock $msock->fileno != $pat->{"sock"}
Truth table0%0/4
A and B and C
A= $pat->{"sock"}B= $msockC= $msock->fileno != $pat->{"sock"}
ABCresult
0XX0
10X0
1100
1111
103 # does not match if sender socket is different
104 0 next;
105 }
106 0 ▶ my $h = $pat->{match} || {};
Condition0%0/2
$pat->{'match'} || {}
l!l
00
MC/DC0%0/1
$pat->{'match'} || {}
$pat->{'match'}
Truth table0%0/2
A
A= $pat->{'match'}
Aresult
11
00
107 0 my $match = 1;
108 0 for my $k (keys %$h) {
109 0 ▶ unless (exists $m->{d}{$k} && $m->{d}{$k} eq $h->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $m->{"d"}{$k} and $m->{"d"}{$k} eq $h->{$k}) 0 0 0
Condition0%0/3
exists $m->{"d"}{$k} and $m->{"d"}{$k} eq $h->{$k}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $m->{"d"}{$k} and $m->{"d"}{$k} eq $h->{$k}
exists $m->{"d"}{$k} $m->{"d"}{$k} eq $h->{$k}
Truth table0%0/3
A and B
A= exists $m->{"d"}{$k}B= $m->{"d"}{$k} eq $h->{$k}
ABresult
0X0
100
111
110 0 $match = 0;
111 0 last;
112 }
113 }
114 0 ▶ next unless $match;
Branch: 1 branch
BranchTrueFalseTotal
unless $match 0 0 0
115 0 debug "MATCH $m->{m}!\n";
116 0 ▶ if ($pat->{filter}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat->{"filter"}) 0 0 0
117 0 ▶ next unless $pat->{filter}->($m->{m}, $m->{d});
Branch: 1 branch
BranchTrueFalseTotal
unless $pat->{"filter"}->($m->{"m"}, $m->{"d"}) 0 0 0
118 }
119 0 splice @msg_queue, $i, 1;
120 0 ▶ my $proc_or_sock = $m->{sock} || ($m->{f} ? IPC::Messaging::Process->_new($m->{f}) : undef);
Branch: 1 branch
BranchTrueFalseTotal
$m->{'f'} ? : 0 0 0
Condition0%0/3
$m->{'sock'} || ($m->{'f'} ? 'IPC::Messaging::Process'->_new($m->{'f'}) : undef)
l!l&&r!l&&!r
000
MC/DC0%0/2
$m->{'sock'} || ($m->{'f'} ? 'IPC::Messaging::Process'->_new($m->{'f'}) : undef)
$m->{'sock'} ($m->{'f'} ? 'IPC::Messaging::Process'->_new($m->{'f'}) : undef)
Truth table0%0/3
A || B
A= $m->{'sock'}B= ($m->{'f'} ? 'IPC::Messaging::Process'->_new($m->{'f'}) : undef)
ABresult
1X1
011
000
121 0 $_ = $proc_or_sock;
122 0 my $ignore = ${$pat->{then}}->($m->{m}, $m->{d}, $proc_or_sock);
123 0 return 1;
124 }
125 }
126 }
127  
128 sub watch_fd
129 2 ▶{
Subroutine watch_fd: called CC=5 SCAR=22.5
Pod undocumented
130 2 my ($fd, $write) = @_;
131 2 ▶ if ($kq) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kq) { } 0 2 2
elsif ($epfd) { } 2 0 2
132 0 ▶ if ($write) {
Branch: 1 branch
BranchTrueFalseTotal
if ($write) { } 0 0 0
133 0 $kq->EV_SET($fd, &IO::KQueue::EVFILT_WRITE, &IO::KQueue::EV_ADD, 0, 0);
134 } else {
135 0 $kq->EV_SET($fd, &IO::KQueue::EVFILT_READ, &IO::KQueue::EV_ADD, 0, 0);
136 }
137 } elsif ($epfd) {
138 2 ▶ if ($write) {
Branch: 1 branch
BranchTrueFalseTotal
if ($write) { } 0 2 2
139 0 IO::Epoll::epoll_ctl($epfd, &IO::Epoll::EPOLL_CTL_ADD, $fd, &IO::Epoll::EPOLLOUT);
140 } else {
141 2 IO::Epoll::epoll_ctl($epfd, &IO::Epoll::EPOLL_CTL_ADD, $fd, &IO::Epoll::EPOLLIN);
142 }
143 }
144 }
145  
146 sub unwatch_fd
147 0 ▶{
Subroutine unwatch_fd: not called CC=7 SCAR=40.3
Pod undocumented
148 0 my ($fd) = @_;
149 0 my $rd = delete $read_socks{$fd};
150 0 my $wr = delete $write_socks{$fd};
151 0 ▶ if ($kq) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kq) { } 0 0 0
elsif ($epfd) { } 0 0 0
152 0 ▶ $kq->EV_SET($fd, &IO::KQueue::EVFILT_READ, &IO::KQueue::EV_DELETE, 0, 0) if $rd;
Branch: 1 branch
BranchTrueFalseTotal
if $rd 0 0 0
153 0 ▶ $kq->EV_SET($fd, &IO::KQueue::EVFILT_WRITE, &IO::KQueue::EV_DELETE, 0, 0) if $wr;
Branch: 1 branch
BranchTrueFalseTotal
if $wr 0 0 0
154 } elsif ($epfd) {
155 0 ▶ IO::Epoll::epoll_ctl($epfd, &IO::Epoll::EPOLL_CTL_DEL, $fd, &IO::Epoll::EPOLLIN) if $rd;
Branch: 1 branch
BranchTrueFalseTotal
if $rd 0 0 0
156 0 ▶ IO::Epoll::epoll_ctl($epfd, &IO::Epoll::EPOLL_CTL_DEL, $fd, &IO::Epoll::EPOLLOUT) if $wr;
Branch: 1 branch
BranchTrueFalseTotal
if $wr 0 0 0
157 }
158 }
159  
160 sub reap_dead_kids
161 0 ▶{
Subroutine reap_dead_kids: not called CC=3 SCAR=24.8
Pod undocumented
162 0 my @to_reap = @processes_to_reap;
163 0 @processes_to_reap = ();
164 0 for my $pid (@to_reap) {
165 0 my $x = waitpid($pid, WNOHANG);
166 0 ▶ push @processes_to_reap, $pid if $x == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $x == 0 0 0 0
167 }
168 }
169  
170 sub pickup_one_message
171 0 ▶{
Subroutine pickup_one_message: not called CC=33 SCAR=70.2
Pod undocumented
172 0 my ($t) = @_;
173 0 debug "$$: select $my_sock $t\n";
174 0 my @fd;
175 0 ▶ reap_dead_kids() if @processes_to_reap;
Branch: 1 branch
BranchTrueFalseTotal
if @processes_to_reap 0 0 0
176 0 ▶ if ($use_kqueue) {
Branch: 2 branches
BranchTrueFalseTotal
if ($use_kqueue) { } 0 0 0
elsif ($use_epoll) { } 0 0 0
177 # XXX errors are ignored, bad
178 0 @fd = map { $_->[&IO::KQueue::KQ_IDENT] } $kq->kevent($t*1000);
179 } elsif ($use_epoll) {
180 # XXX errors are ignored, bad
181 0 ▶ @fd = map { $_->[0] } @{IO::Epoll::epoll_wait($epfd, 100, $t*1000) || []};
Condition0%0/2
IO::Epoll::epoll_wait($epfd, 100, $t * 1000) || []
l!l
00
MC/DC0%0/1
IO::Epoll::epoll_wait($epfd, 100, $t * 1000) || []
IO::Epoll::epoll_wait($epfd, 100, $t * 1000)
Truth table0%0/2
A
A= IO::Epoll::epoll_wait($epfd, 100, $t * 1000)
Aresult
11
00
182 } else {
183 0 my $to_read = IO::Select->new($my_sock,map { $_->{sock} } values %read_socks);
184 0 my $to_write = IO::Select->new(map { $_->{sock} } values %write_socks);
185 0 my ($r,$w) = IO::Select->select($to_read, $to_write, undef, $t);
186 0 @fd = map { $_->fileno } @$w, @$r;
187 }
188 0 for my $fd (@fd) {
189 0 ▶ if ($fd == $my_sock_fileno) {
Branch: 3 branches
BranchTrueFalseTotal
if ($fd == $my_sock_fileno) { } 0 0 0
elsif ($write_socks{$fd}) { } 0 0 0
elsif ($read_socks{$fd}) { } 0 0 0
190 0 my $data = "";
191 0 $my_sock->recv($data, $MAX_DGRAM_SIZE);
192 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
193 0 debug "$$: got something:\n\t$data\n";
194 0 my $msg = eval { Storable::thaw($data) };
195 0 ▶ debug "$$: cannot thaw: $@\n" if !$msg && $@;
Branch: 1 branch
BranchTrueFalseTotal
if not $msg and $@ 0 0 0
Condition0%0/3
not $msg and $@
!ll&&!rl&&r
000
MC/DC0%0/2
not $msg and $@
not $msg $@
Truth table0%0/3
not(A) and B
A= not $msgB= $@
ABresult
0X0
100
111
196 0 ▶ return unless $msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg 0 0 0
197 0 ▶ return unless $msg->{s} && $msg->{s} eq $secret && $msg->{m} && $msg->{f};
Branch: 1 branch
BranchTrueFalseTotal
unless $msg->{"s"} and $msg->{"s"} eq $secret and $msg->{"m"} and $msg->{"f"} 0 0 0
Condition0%0/9
$msg->{"s"} and $msg->{"s"} eq $secret and $msg->{"m"} and $msg->{"f"}
!ll&&!rl&&r
000
$msg->{"s"} and $msg->{"s"} eq $secret and $msg->{"m"}
!ll&&!rl&&r
000
$msg->{"s"} and $msg->{"s"} eq $secret
!ll&&!rl&&r
000
MC/DC0%0/4
$msg->{"s"} and $msg->{"s"} eq $secret and $msg->{"m"} and $msg->{"f"}
$msg->{"s"} $msg->{"s"} eq $secret $msg->{"m"} $msg->{"f"}
Truth table0%0/5
A and B and C and D
A= $msg->{"s"}B= $msg->{"s"} eq $secretC= $msg->{"m"}D= $msg->{"f"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
198 0 ▶ $msg->{d} ||= {};
Condition0%0/2
$msg->{"d"} ||= {}
l!l
00
MC/DC0%0/1
$msg->{"d"} ||= {}
$msg->{"d"}
Truth table0%0/2
A
A= $msg->{"d"}
Aresult
11
00
199 0 push @msg_queue, $msg;
200 0 ▶ if ($msg->{m} eq "EXIT") {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg->{"m"} eq "EXIT") 0 0 0
201 0 my $x = waitpid($msg->{f}, WNOHANG);
202 0 ▶ push @processes_to_reap, $msg->{f} if $x == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $x == 0 0 0 0
203 }
204 } elsif ($write_socks{$fd}) {
205 0 my $s = $write_socks{$fd};
206 0 unwatch_fd($fd);
207 0 ▶ if ($s->{type} eq "tcp_connecting") {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{"type"} eq "tcp_connecting") 0 0 0
208 0 my $sock = $s->{sock};
209 0 my $peer = $sock->peerhost;
210 0 my $peer_port = $sock->peerport;
211 0 my $opt = getsockopt($sock, SOL_SOCKET, SO_ERROR);
212 0 ▶ $opt = unpack("I", $opt) if defined $opt;
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt 0 0 0
213 0 ▶ if ($opt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt) { } 0 0 0
214 0 push @msg_queue, {
215 m => "tcp_error",
216 sock => $sock,
217 d => {
218 errno => $opt,
219 },
220 };
221 } else {
222 0 push @msg_queue, {
223 m => "tcp_connected",
224 sock => $sock,
225 d => {
226 peer => $peer,
227 peer_port => $peer_port,
228 },
229 };
230 $read_socks{$fd} = {
231 sock => $s->{sock},
232 type => "tcp",
233 by_line => $s->{by_line},
234 0 from => $peer,
235 from_port => $peer_port,
236 };
237 0 watch_fd($fd);
238 }
239 }
240 } elsif ($read_socks{$fd}) {
241 0 my $s = $read_socks{$fd};
242 0 ▶ if ($s->{type} eq "tcp_listen") {
Branch: 3 branches
BranchTrueFalseTotal
if ($s->{'type'} eq 'tcp_listen') { } 0 0 0
elsif ($s->{'type'} eq 'tcp') { } 0 0 0
elsif ($s->{'type'} eq 'udp') { } 0 0 0
243 0 my $sock = $s->{sock}->accept;
244 0 my $from = $sock->peerhost;
245 0 my $from_port = $sock->peerport;
246 push @msg_queue, {
247 m => "tcp_connect",
248 fsock => $s->{sock},
249 0 sock => $sock,
250 d => {
251 from => $from,
252 from_port => $from_port,
253 },
254 };
255 $read_socks{$sock->fileno} = {
256 sock => $sock,
257 type => "tcp",
258 from => $from,
259 from_port => $from_port,
260 by_line => $s->{by_line},
261 0 buf => "",
262 };
263 0 watch_fd($sock->fileno);
264 } elsif ($s->{type} eq "tcp") {
265 0 my $d = "";
266 0 my $sock = $s->{sock};
267 0 my $len = sysread $sock, $d, $TCP_READ_SIZE;
268 0 ▶ if (!defined $len || $len <= 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $len or $len <= 0) { } 0 0 0
elsif ($s->{'by_line'}) { } 0 0 0
Condition0%0/3
not defined $len or $len <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $len or $len <= 0
not defined $len $len <= 0
Truth table0%0/3
not(A) or B
A= not defined $lenB= $len <= 0
ABresult
1X1
011
000
269 0 ▶ if ($s->{buf} && $s->{by_line}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{"buf"} and $s->{"by_line"}) 0 0 0
Condition0%0/3
$s->{"buf"} and $s->{"by_line"}
!ll&&!rl&&r
000
MC/DC0%0/2
$s->{"buf"} and $s->{"by_line"}
$s->{"buf"} $s->{"by_line"}
Truth table0%0/3
A and B
A= $s->{"buf"}B= $s->{"by_line"}
ABresult
0X0
100
111
270 push @msg_queue, {
271 m => "tcp_line",
272 sock => $sock,
273 d => {
274 from => $s->{from},
275 from_port => $s->{from_port},
276 line => $s->{buf},
277 },
278 0 };
279 }
280 push @msg_queue, {
281 m => "tcp_disconnect",
282 d => {
283 from => $s->{from},
284 from_port => $s->{from_port},
285 },
286 0 };
287 0 unwatch_fd($fd);
288 0 $sock->close;
289 } elsif ($s->{by_line}) {
290 0 $s->{buf} .= $d;
291 0 ▶ while ($s->{buf} =~ s/^(.*?\n)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{"buf"} =~ s/^(.*?\n)//) 0 0 0
292 push @msg_queue, {
293 m => "tcp_line",
294 sock => $sock,
295 d => {
296 from => $s->{from},
297 from_port => $s->{from_port},
298 0 line => $1,
299 },
300 };
301 }
302 } else {
303 push @msg_queue, {
304 m => "tcp_data",
305 sock => $sock,
306 d => {
307 from => $s->{from},
308 from_port => $s->{from_port},
309 0 data => $d,
310 },
311 };
312 }
313 } elsif ($s->{type} eq "udp") {
314 0 my $d = "";
315 0 my $sock = $s->{sock};
316 0 $sock->recv($d, $MAX_DGRAM_SIZE);
317 0 ▶ return unless $d;
Branch: 1 branch
BranchTrueFalseTotal
unless $d 0 0 0
318 0 debug "$$: got udp\n";
319 0 push @msg_queue, {
320 m => "udp",
321 sock => $sock,
322 d => {
323 from => $sock->peerhost,
324 from_port => $sock->peerport,
325 data => $d,
326 },
327 };
328 } else {
329 # XXX
330 # Something is fishy, we don't know what to do with this
331 # socket, so unwatch it in order to not have the "always ready"
332 # condition.
333 0 unwatch_fd($fd);
334 }
335 }
336 }
337 }
338  
339 sub tcp_server
340 0 ▶{
Subroutine tcp_server: not called CC=4 SCAR=30.0
Pod undocumented
341 0 my (undef, $port, %p) = @_;
342 my $sock = IO::Socket::INET->new(
343 Listen => $p{listen_queue} || 5,
344 0 ▶ ($p{bind} ? (LocalAddr => $p{bind}) : ()),
Branch: 2 branches
BranchTrueFalseTotal
my $sock = "IO::Socket::INET"->new("Listen", $p{"listen_queue"} || 5, $p{"bind"} ? ("LocalAddr", $p{"bind"}) : (), "LocalPort", $port, "Proto", "tcp", "ReuseAddr", 1) or die $@ 0 0 0
$p{'bind'} ? : 0 0 0
Condition0%0/2
$p{'listen_queue'} || 5
l!l
00
MC/DC0%0/1
$p{'listen_queue'} || 5
$p{'listen_queue'}
Truth table0%0/2
A
A= $p{'listen_queue'}
Aresult
11
00
345 LocalPort => $port,
346 Proto => "tcp",
347 ReuseAddr => 1,
348 ) or die $@;
349 $read_socks{$sock->fileno} = {
350 sock => $sock,
351 type => "tcp_listen",
352 by_line => $p{by_line},
353 0 };
354 0 watch_fd($sock->fileno);
355 0 return $sock;
356 }
357  
358 sub tcp_client
359 0 ▶{
Subroutine tcp_client: not called CC=2 SCAR=17.9
Pod undocumented
360 0 my (undef, $host, $port, %p) = @_;
361 0 ▶ my $sock = IO::Socket::INET->new(
Branch: 1 branch
BranchTrueFalseTotal
my $sock = "IO::Socket::INET"->new("Proto", "tcp", "PeerHost", $host, "PeerPort", $port, "Blocking", 0) or die $@ 0 0 0
362 Proto => "tcp",
363 PeerHost => $host,
364 PeerPort => $port,
365 Blocking => 0,
366 ) or die $@;
367 $write_socks{$sock->fileno} = {
368 sock => $sock,
369 type => "tcp_connecting",
370 by_line => $p{by_line},
371 0 };
372 0 watch_fd($sock->fileno, "write");
373 0 return $sock;
374 }
375  
376 sub udp
377 0 ▶{
Subroutine udp: not called CC=4 SCAR=30.0
Pod undocumented
378 0 my (undef, $port, $bind) = @_;
379 0 ▶ $port ||= 0;
Condition0%0/2
$port ||= 0
l!l
00
MC/DC0%0/1
$port ||= 0
$port
Truth table0%0/2
A
A= $port
Aresult
11
00
380 0 ▶ my $sock = IPC::Messaging::UDP->new(
Branch: 2 branches
BranchTrueFalseTotal
my $sock = "IPC::Messaging::UDP"->new("Proto", "udp", "LocalPort", $port, $bind ? ("LocalAddr", $bind) : (), "ReuseAddr", 1) or die $@ 0 0 0
$bind ? : 0 0 0
381 Proto => "udp",
382 LocalPort => $port,
383 ($bind ? (LocalAddr => $bind) : ()),
384 ReuseAddr => 1,
385 ) or die $@;
386 0 $read_socks{$sock->fileno} = {
387 sock => $sock,
388 type => "udp",
389 };
390 0 watch_fd($sock->fileno);
391 0 return $sock;
392 }
393  
394 sub receive_parse
395 10 ▶{
Subroutine receive_parse: called CC=6 SCAR=22.4
Pod undocumented
396 10 my ($rsub) = @_;
397 10 ▶ die "internal error: non-empty \$recv" if $recv;
Branch: 1 branch
BranchTrueFalseTotal
if $recv 0 10 10
398 10 my $r = $recv = { then_balance => 0 };
399 10 eval { $rsub->(); };
400 10 $recv = undef;
401 10 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 9 1 10
402 1 ▶ croak "dangling \"then\"" if $r->{then_balance};
Branch: 1 branch
BranchTrueFalseTotal
if $r->{"then_balance"} 1 0 1
403 0 ▶ unless ($r->{pats} || $r->{timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r->{"pats"} or $r->{"timeout"}) 0 0 0
Condition0%0/3
$r->{"pats"} or $r->{"timeout"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$r->{"pats"} or $r->{"timeout"}
$r->{"pats"} $r->{"timeout"}
Truth table0%0/3
A or B
A= $r->{"pats"}B= $r->{"timeout"}
ABresult
1X1
011
000
404 0 die "an empty \"receive\"";
405 }
406 0 $r;
407 }
408  
409 sub receive_once
410 0 ▶{
Subroutine receive_once: not called CC=9 SCAR=45.0
Pod undocumented
411 0 my ($r) = @_;
412 0 my $start = Time::HiRes::time;
413 0 while (1) {
414 0 ▶ if (!$i_am_root && !kill 0, $root) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i_am_root or kill 0, $root) 0 0 0
Condition0%0/3
$i_am_root or kill 0, $root
l!l&&r!l&&!r
000
MC/DC0%0/2
$i_am_root or kill 0, $root
$i_am_root kill 0, $root
Truth table0%0/3
A or B
A= $i_am_rootB= kill 0, $root
ABresult
1X1
011
000
415 0 die "root process has quit, aborting";
416 }
417 0 ▶ if (run_queue($r)) {
Branch: 1 branch
BranchTrueFalseTotal
if (run_queue($r)) 0 0 0
418 0 debug "$$: first pickup\n";
419 0 pickup_one_message(0);
420 0 last;
421 }
422 0 ▶ if ($r->{timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r->{'timeout'}) { } 0 0 0
423 0 debug "$$: pickup with timeout\n";
424 0 debug "$r->{timeout}[0] ", Time::HiRes::time(), " $start\n";
425 0 ▶ next if pickup_one_message($r->{timeout}[0]-(Time::HiRes::time()-$start));
Branch: 1 branch
BranchTrueFalseTotal
if pickup_one_message($r->{"timeout"}[0] - (&Time::HiRes::time() - $start)) 0 0 0
426 } else {
427 0 debug "$$: indefinite pickup\n";
428 0 ▶ next if pickup_one_message(5);
Branch: 1 branch
BranchTrueFalseTotal
if pickup_one_message(5) 0 0 0
429 }
430 0 ▶ if ($r->{timeout} && $r->{timeout}[0]-(Time::HiRes::time()-$start) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r->{"timeout"} and $r->{"timeout"}[0] - (&Time::HiRes::time() - $start) < 0) 0 0 0
Condition0%0/3
$r->{"timeout"} and $r->{"timeout"}[0] - (&Time::HiRes::time() - $start) < 0
!ll&&!rl&&r
000
MC/DC0%0/2
$r->{"timeout"} and $r->{"timeout"}[0] - (&Time::HiRes::time() - $start) < 0
$r->{"timeout"} $r->{"timeout"}[0] - (&Time::HiRes::time() - $start) < 0
Truth table0%0/3
A and B
A= $r->{"timeout"}B= $r->{"timeout"}[0] - (&Time::HiRes::time() - $start) < 0
ABresult
0X0
100
111
431 0 debug "$$: timeout!\n";
432 0 ${$r->{timeout}[1]}->();
433 0 last;
434 }
435 }
436 }
437  
438 sub receive (&)
439 10 ▶{
Subroutine receive: called CC=1 SCAR=1.2
Pod undocumented
440 10 my $r = receive_parse(@_);
441 0 receive_once($r);
442 }
443  
444 sub receive_loop (&)
445 0 ▶{
Subroutine receive_loop: not called CC=1 SCAR=6.9
Pod undocumented
446 0 my $r = receive_parse(@_);
447 0 receive_once($r) while 1;
448 }
449  
450 sub got
451 8 ▶{
Subroutine got: called CC=18 SCAR=33.0
Pod undocumented
452 8 my (@p) = @_;
453 8 ▶ die "\"got\" outside \"receive\"" unless $recv;
Branch: 1 branch
BranchTrueFalseTotal
unless $recv 1 7 8
454 7 ▶ die "invalid \"got\" syntax: not enough arguments" unless @p >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @p >= 2 1 6 7
455 6 my $pat = {};
456 6 $pat->{then} = pop @p;
457 die "invalid \"got\" syntax: missing \"then\""
458 6 ▶ unless UNIVERSAL::isa($pat->{then}, "IPC::Messaging::Then");
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($pat->{"then"}, "IPC::Messaging::Then") 1 5 6
459 5 ▶ if (UNIVERSAL::isa($p[0], "ARRAY")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($p[0], "ARRAY")) 3 2 5
460 3 ▶ if (@p != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p != 1) 1 2 3
461 1 die "invalid \"got\" syntax: arrayref not by itself";
462 }
463 2 @p = @{$p[0]};
464 }
465 4 ▶ die "invalid \"got\" syntax: missing message name" unless @p;
Branch: 1 branch
BranchTrueFalseTotal
unless @p 1 3 4
466 3 my $name = shift @p;
467 3 ▶ die "invalid \"got\" syntax: message name must not be a reference" if ref $name;
Branch: 1 branch
BranchTrueFalseTotal
if ref $name 1 2 3
468 2 $pat->{name} = $name;
469 2 ▶ if (@p) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p) 2 0 2
470 2 my $from = $p[0];
471 2 ▶ if (UNIVERSAL::isa($from, "IPC::Messaging::Process")) {
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($from, 'IPC::Messaging::Process')) { } 0 2 2
elsif (UNIVERSAL::isa($from, 'IO::Handle')) { } 0 2 2
472 0 $pat->{proc} = "$from";
473 0 shift @p;
474 } elsif (UNIVERSAL::isa($from, "IO::Handle")) {
475 0 $pat->{sock} = $from->fileno;
476 0 shift @p;
477 }
478 }
479 2 ▶ if (@p) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p) 2 0 2
480 2 ▶ if (UNIVERSAL::isa($p[0], "CODE")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($p[0], "CODE")) 0 2 2
481 0 $pat->{filter} = shift @p;
482 }
483 }
484 2 ▶ if (@p) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p) 2 0 2
485 2 ▶ if (UNIVERSAL::isa($p[0], "HASH")) {
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($p[0], 'HASH')) { } 1 1 2
elsif (@p % 2 != 0) { } 1 0 1
486 1 ▶ die "invalid \"got\" syntax: unexpected hashref" unless @p == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @p == 1 1 0 1
487 0 @p = %{$p[0]};
488 } elsif (@p % 2 != 0) {
489 1 die "invalid \"got\" syntax: odd number of matching elements";
490 }
491 }
492 0 ▶ $pat->{match} = {@p} if @p;
Branch: 1 branch
BranchTrueFalseTotal
if @p 0 0 0
493 0 push @{$recv->{pats}}, $pat;
494 0 $recv->{then_balance}--;
495 }
496  
497 sub then (&)
498 9 ▶{
Subroutine then: called CC=2 SCAR=6.9
Pod undocumented
499 9 my ($act) = @_;
500 9 ▶ die "\"then\" outside \"receive\"" unless $recv;
Branch: 1 branch
BranchTrueFalseTotal
unless $recv 1 8 9
501 8 $recv->{then_balance}++;
502 8 bless \$act, "IPC::Messaging::Then";
503 }
504  
505 sub after ($$)
506 4 ▶{
Subroutine after: called CC=4 SCAR=13.9
Pod undocumented
507 4 my ($t, $then) = @_;
508 4 ▶ die "\"after\" outside \"receive\"" unless $recv;
Branch: 1 branch
BranchTrueFalseTotal
unless $recv 1 3 4
509 3 ▶ die "invalid \"after\" syntax: missing \"then\""
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($then, "IPC::Messaging::Then") 1 2 3
510 unless UNIVERSAL::isa($then, "IPC::Messaging::Then");
511 2 ▶ die "duplicate \"after\" in \"receive\"" if $recv->{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $recv->{"timeout"} 1 1 2
512 1 $recv->{then_balance}--;
513 1 $recv->{timeout} = [$t, $then];
514 }
515  
516 sub timer
517 0 ▶{
Subroutine timer: not called CC=1 SCAR=6.9
Pod undocumented
518 0 my (undef, $interval, %msg) = @_;
519 0 die "timers are not implemented yet\n";
520 0 return IPC::Messaging::Timer->new($interval, %msg);
521 }
522  
523 sub global_init
524 2 ▶{
Subroutine global_init: called CC=8 SCAR=25.3
Pod undocumented
525 2 $secret = int(rand(10000))+1;
526 2 $root = $$;
527 2 $i_am_root = 1;
528 2 $messaging_dir = "/tmp/ipc-messaging-$>/$root";
529 2 ▶ system("rm -rf $messaging_dir") if -e $messaging_dir && !-l $messaging_dir;
Branch: 1 branch
BranchTrueFalseTotal
if -e $messaging_dir and not -l $messaging_dir 0 2 2
Condition33%1/3
-e $messaging_dir and not -l $messaging_dir
!ll&&!rl&&r
200
MC/DC0%0/2
-e $messaging_dir and not -l $messaging_dir
-e $messaging_dir not -l $messaging_dir
Truth table33%1/3
A and not(B)
A= -e $messaging_dirB= not -l $messaging_dir
ABresult
0X0
100
111
530 2 system("mkdir -p $messaging_dir");
531 2 $use_kqueue = can_load(modules => { "IO::KQueue" => 0 });
532 2 $use_epoll = can_load(modules => { "IO::Epoll" => 0 });
533 2 ▶ $use_select = !$use_kqueue && !$use_epoll && can_load(modules => { "IO::Select" => 0 });
Condition33%2/6
!($use_kqueue || $use_epoll) && can_load('modules', {'IO::Select', 0})
!ll&&!rl&&r
200
$use_kqueue || $use_epoll
l!l&&r!l&&!r
020
MC/DC0%0/3
!($use_kqueue || $use_epoll) && can_load('modules', {'IO::Select', 0})
$use_kqueue $use_epoll can_load('modules', {'IO::Select', 0})
Truth table25%1/4
not(A || B) && C
A= $use_kqueueB= $use_epollC= can_load('modules', {'IO::Select', 0})
ABCresult
1XX0
01X0
0000
0011
534 2 ▶ die "cannot find neither IO::KQueue nor IO::Epoll nor IO::Select"
Branch: 1 branch
BranchTrueFalseTotal
unless $use_kqueue or $use_epoll or $use_select 0 2 2
Condition33%2/6
$use_kqueue or $use_epoll or $use_select
l!l&&r!l&&!r
200
$use_kqueue or $use_epoll
l!l&&r!l&&!r
020
MC/DC0%0/3
$use_kqueue or $use_epoll or $use_select
$use_kqueue $use_epoll $use_select
Truth table25%1/4
A or B or C
A= $use_kqueueB= $use_epollC= $use_select
ABCresult
1XX1
01X1
0011
0000
535 unless $use_kqueue || $use_epoll || $use_select;
536 }
537  
538 sub initpid
539 2 ▶{
Subroutine initpid: called CC=6 SCAR=18.4
Pod undocumented
540 2 ▶ return if ref $$;
Branch: 1 branch
BranchTrueFalseTotal
if ref $$ 0 2 2
541 2 ▶ global_init() unless $secret;
Branch: 1 branch
BranchTrueFalseTotal
unless $secret 2 0 2
542 2 my $this = IPC::Messaging::Process->_new($$);
543 2 my $pid = B::svref_2object(\$$);
544 2 $pid->FLAGS($pid->FLAGS & ~B::SVf_READONLY);
545 2 $$ = $this;
546 2 $pid->FLAGS($pid->FLAGS | B::SVf_READONLY);
547  
548 2 ▶ $kq = IO::KQueue->new if $use_kqueue;
Branch: 1 branch
BranchTrueFalseTotal
if $use_kqueue 0 2 2
549 2 ▶ $epfd = IO::Epoll::epoll_create(100) if $use_epoll;
Branch: 1 branch
BranchTrueFalseTotal
if $use_epoll 2 0 2
550  
551 2 ▶ $my_sock = IO::Socket::UNIX->new(
Branch: 1 branch
BranchTrueFalseTotal
$my_sock = "IO::Socket::UNIX"->new("Local", "$messaging_dir/${$}.sock", "Type", 2) or die $@ 2 0 2
552 Local => "$messaging_dir/$$.sock",
553 Type => SOCK_DGRAM)
554 or die $@;
555 2 $my_sock_fileno = $my_sock->fileno;
556 2 watch_fd($my_sock_fileno);
557 2 %their_sock = ();
558 2 @msg_queue = ();
559 2 %read_socks = ();
560 }
561  
562 package IPC::Messaging::Process;
563 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
564 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
565 2 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
566 2 ▶use IO::Socket::UNIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
567 2 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
568  
569 2 ▶use overload '0+' => \&_numify;
Subroutine BEGIN: called CC=1 SCAR=0.0
570 2 ▶use overload '""' => \&_stringify;
Subroutine BEGIN: called CC=1 SCAR=0.0
571 2 ▶use overload '<=>' => sub { "$_[0]" <=> "$_[1]" };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
572 0 ▶use overload 'cmp' => sub { "$_[0]" cmp "$_[1]" };
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
573  
574 sub _new
575 2 ▶{
Subroutine _new: called CC=1 SCAR=0.0
576 2 my ($pkg, $pid) = @_;
577 2 my $me = {pid => $pid};
578 2 bless $me, $pkg;
579 }
580  
581 sub _numify
582 0 ▶{
Subroutine _numify: not called CC=1 SCAR=6.9
583 0 return $_[0]->{pid};
584 }
585  
586 sub _stringify
587 40 ▶{
Subroutine _stringify: called CC=1 SCAR=0.0
588 40 return "$_[0]->{pid}";
589 }
590  
591 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
592  
593 sub AUTOLOAD
594 0 ▶{
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
595 0 my $proc = shift;
596 0 my $name = $AUTOLOAD;
597 0 $name =~ s/^IPC::Messaging::Process:://;
598 0 my $m = {
599 m => $name,
600 f => "$$",
601 s => $secret,
602 d => {@_},
603 };
604 0 my $data = Storable::freeze($m);
605 0 my $sock = $their_sock{"$proc"};
606 0 ▶ unless ($sock) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sock) 0 0 0
607 0 $sock = $their_sock{"$proc"} = IO::Socket::UNIX->new(
608 Peer => "$messaging_dir/$proc.sock",
609 Type => SOCK_DGRAM,
610 Timeout => 10);
611 }
612 0 ▶ die "cannot create peer socket: $!" unless $sock;
Branch: 1 branch
BranchTrueFalseTotal
unless $sock 0 0 0
613 0 IPC::Messaging::debug "$$: sending to $messaging_dir/$proc.sock:\n\t$data\n";
614 0 $sock->send($data);
615 }
616  
617 package IPC::Messaging::Then;
618  
619 package IPC::Messaging::UDP;
620 2 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
621 2 ▶use base 'IO::Socket::INET';
Subroutine BEGIN: called CC=1 SCAR=0.0
622  
623 sub sendto
624 0 ▶{
Subroutine sendto: not called CC=1 SCAR=6.9
625 0 my ($socket, $data, $addr, $port) = @_;
626 0 my $iaddr = Socket::inet_aton($addr);
627 0 send $socket, $data, 0, scalar Socket::sockaddr_in($port, $iaddr);
628 }
629  
630 package IPC::Messaging::Timer;
631  
632 2 our $COUNT;
633 2 our %ACTIVE;
634 2 our %SUSPENDED;
635  
636 sub new
637 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
638 0 my ($class, $interval, %msg) = @_;
639  
640 0 my $me = {
641 interval => $interval,
642 start => Time::HiRes::time,
643 id => ++$COUNT,
644 };
645 }
646  
647 sub reset
648 0 ▶{
Subroutine reset: not called CC=1 SCAR=6.9
649 0 my ($me) = @_;
650 0 $me->{start} = Time::HiRes::time;
651 }
652  
653 package IPC::Messaging;
654  
655 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=4.6
656 2 initpid();
657 0 ▶ *CORE::GLOBAL::fork = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
658 0 my $r = fork;
659 0 ▶ if (defined $r && !$r) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r and not $r) 0 0 0
Condition0%0/3
defined $r and not $r
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r and not $r
defined $r not $r
Truth table0%0/3
A and not(B)
A= defined $rB= not $r
ABresult
0X0
100
111
660 0 $secret = 0;
661 0 initpid();
662 }
663 0 $r;
664 2 };
665 }
666  
667 2 1;
668 __END__
↑ Summary