Branch Coverage

blib/lib/Net/Server.pm
Criterion Covered Total %
branch 188 418 44.9


line true false branch
36 3 68 @_ == 1 ? :
45 8 62 ref $_[0] ? :
46 3 67 @_ == 1 ? :
72 13 0 if ($ok) { }
89 70 3 unless eval { do { local $SIG{'__DIE__'}; $self->commandline } }
93 0 73 unless $self->default_values
94 20 53 if @defaults
99 70 0 ref $_[0] ? :
70 73 if @_
106 70 0 if $script =~ m[^[^/]+/] and $ENV{'PWD'}
116 27 73 $_[0] && ref $_[0] ? :
118 4 96 if @ARGV
119 100 0 if $prop->{'_run_args'}
121 8 92 if ($prop->{'conf_file'}) { }
125 1 91 if $def->{'conf_file'}
135 70 0 unless defined $prop->{'log_level'} and $prop->{'log_level'} =~ /^\d+$/
136 0 70 if $prop->{'log_level'} > 4
139 0 70 if ($prop->{'pid_file'})
140 0 0 unless (eval { do { &check_pid_file($prop->{'pid_file'}) } })
141 0 0 unless $ENV{'BOUND_SOCKETS'}
146 69 1 unless ($prop->{'_is_inet'})
147 0 69 if ($prop->{'setsid'} or length $prop->{'log_file'})
148 0 0 unless open STDIN, '<', '/dev/null'
149 0 0 unless open STDOUT, '>', '/dev/null'
153 70 0 unless ($ENV{'BOUND_SOCKETS'})
154 0 70 if ($prop->{'setsid'} or $prop->{'background'})
156 0 0 unless defined $pid
157 0 0 if $pid
161 0 70 if $prop->{'setsid'}
164 0 70 if (length $prop->{'log_file'} and not $prop->{'log_function'}) { }
0 70 elsif ($prop->{'setsid'}) { }
173 0 70 if ($prop->{'pid_file'})
174 0 0 if (eval { do { &create_pid_file($prop->{'pid_file'}) } }) { }
188 70 0 unless (defined $prop->{'log_file'})
194 0 0 if ($prop->{'log_file'} =~ /^([a-zA-Z]\w*(?:::[a-zA-Z]\w*)*)$/)
197 0 0 if (eval { do { require $file } }) { }
0 0 elsif ($file =~ /::/ or grep {-e "$_/$file";} @INC) { }
207 0 0 unless $prop->{'log_file'} =~ m(^([\:\w\.\-/\\]+)$)
209 0 0 unless open _SERVER_LOG, '>>', $prop->{'log_file'}
225 3 66 if ($self->isa('Net::Server::MultiType'))
229 69 0 if $type ne $super
233 0 69 if not @{$prop->{'sock'};}
242 7 62 if (not defined $ports or ref $ports and not @$ports)
244 0 7 if (not defined $ports or ref $ports and not @$ports)
252 62 7 ref $ports ? :
253 82 18 @$bind >= @$hosts ? :
100 0 ref $hosts ? :
254 90 10 @$bind >= @$protos ? :
100 0 ref $protos ? :
255 87 13 @$bind >= @$ipvs ? :
100 0 ref $ipvs ? :
258 0 100 if ($port ne '0' and $bound{"$host\e$port\e$proto\e$ipv"}++)
283 0 12 if (exists $ENV{'BOUND_SOCKETS'}) { }
289 0 0 unless defined $orig
290 0 0 $fd =~ /^(\d+)$/ ? :
295 0 0 if (my $ref = $map{$sock->hup_string}) { }
299 0 0 unless keys %$ref
321 7 5 if (@{$prop->{'sock'};} > 1 or $prop->{'multi_port'}) { }
338 13 0 if (not defined $prop->{'group'}) { }
0 0 elsif ($prop->{'group'} =~ /^([\w-]+(?: [\w-]+)*)$/) { }
343 0 0 if $@
348 13 0 if (not defined $prop->{'user'}) { }
0 0 elsif ($prop->{'user'} =~ /^([\w-]+)$/) { }
353 0 0 if $@
359 0 13 if ($prop->{'group'} ne $) or $prop->{'user'} ne $>)
362 0 0 if $prop->{'pid_file_unlink'}
363 0 0 if $prop->{'lock_file_unlink'}
364 0 0 unless $prop->{'chown_files'}
368 0 0 unless chown $uid, $gid, $file
372 0 13 if ($prop->{'chroot'})
373 0 0 unless -d $prop->{'chroot'}
375 0 0 unless chroot $prop->{'chroot'}
380 0 13 if ($prop->{'group'} ne $))
384 0 13 if ($prop->{'user'} ne $>)
389 0 13 if ($@)
390 0 0 if ($> == 0) { }
0 0 elsif ($< == 0) { }
418 2 3 if $self->done
429 8 5 if ($prop->{'multi_port'}) { }
430 0 8 if $prop->{'_HUP'}
432 0 7 if $prop->{'_HUP'}
433 0 7 if ($self->can_read_hook($sock))
440 0 12 unless defined $sock
442 1 11 if (2 == $sock->getsockopt(1, 3)) { }
452 0 12 if $prop->{'_HUP'}
453 12 0 if $prop->{'client'}
466 0 7 unless @waiting
478 1 11 if $prop->{'udp_true'}
480 0 11 unless ($client)
485 3 8 if $client->can('post_accept')
486 10 1 if (not $prop->{'no_client_stdout'})
489 4 6 if ($prop->{'tie_client_stdout'} or $client->can('tie_stdout') and $client->tie_stdout) { }
6 0 elsif (defined(my $fileno = fileno $prop->{'client'})) { }
490 0 4 unless open STDIN, '<', '/dev/null'
491 0 4 unless open STDOUT, '>', '/dev/null'
492 0 4 unless tie *STDOUT, 'Net::Server::TiedHandle', $client, $prop->{'tied_stdout_callback'}
493 0 4 unless tie *STDIN, 'Net::Server::TiedHandle', $client, $prop->{'tied_stdin_callback'}
495 0 6 unless open STDIN, '<&', $fileno
496 0 6 unless open STDOUT, '>&', $fileno
512 0 12 if ($client->NS_proto =~ /^UNIX/)
514 0 0 if $prop->{'log_level'} and 3 <= $prop->{'log_level'}
518 12 0 if (my $sockname = $client->sockname) { }
526 1 11 if ($prop->{'udp_true'}) { }
11 0 elsif ($prop->{'peername'} = $client->peername) { }
527 1 0 if ($client->sockdomain == 2) { }
532 0 0 'Socket6'->can('inet_ntop') ? :
544 0 12 if ($addr and defined $prop->{'reverse_lookups'})
545 0 0 if ($INC{'Socket6.pm'} and 'Socket6'->can('getnameinfo')) { }
547 0 0 if @res > 1
556 0 12 if $prop->{'log_level'} and 3 <= $prop->{'log_level'}
567 0 13 if $sock and $sock->NS_proto =~ /^UNIX/
573 13 0 unless @{$prop->{'allow'};} or @{$prop->{'deny'};} or @{$prop->{'cidr_allow'};} or @{$prop->{'cidr_deny'};}
577 0 0 $prop->{'peeraddr'} =~ /^\s*::ffff:([0-9.]+\s*)$/ ? :
582 0 0 if $prop->{'reverse_lookups'} and defined $prop->{'peerhost'} and $prop->{'peerhost'} =~ /^$_$/
583 0 0 if $peeraddr =~ /^$_$/
585 0 0 if (@{$prop->{'cidr_deny'};})
587 0 0 if Net::CIDR::cidrlookup($peeraddr, @{$$prop{'cidr_deny'};})
593 0 0 if $prop->{'reverse_lookups'} and defined $prop->{'peerhost'} and $prop->{'peerhost'} =~ /^$_$/
594 0 0 if $peeraddr =~ /^$_$/
596 0 0 if (@{$prop->{'cidr_allow'};})
598 0 0 if Net::CIDR::cidrlookup($peeraddr, @{$$prop{'cidr_allow'};})
612 1 9 if ($prop->{'udp_true'})
614 0 1 if ($prop->{'udp_data'} =~ /dump/)
629 0 9 if (/get\s+(\w+)/) { }
0 9 elsif (/dump/) { }
3 6 elsif (/quit/) { }
6 0 elsif (/exit/) { }
638 0 3 if $@ eq "Timed Out!\n"
653 1 5 if $prop->{'udp_true'}
655 4 1 unless ($prop->{'no_client_stdout'})
656 2 2 if ($t)
657 2 2 if ($t)
658 0 4 unless open STDIN, '<', '/dev/null'
659 0 4 unless open STDOUT, '>', '/dev/null'
666 0 3 if @_
678 0 0 unless defined $pid
679 0 0 unless ($pid)
693 0 0 if $self->{'server'}{'children'}
713 0 3 if (defined $prop->{'ppid'} and $prop->{'ppid'} != $$ and not defined $prop->{'no_close_by_child'})
724 0 0 if ($prop->{'kind_quit'} and $prop->{'children'})
730 0 0 if $self->can('coordinate_children')
731 0 0 unless keys %{$$self{'server'}{'children'};}
736 0 12 if ($prop->{'_HUP'} and $prop->{'leave_children_open_on_hup'}) { }
740 3 9 if $prop->{'children'}
744 2 0 if (defined $prop->{'lock_file'} and -e $prop->{'lock_file'} and defined $prop->{'lock_file_unlink'})
747 0 2 unless unlink $prop->{'lock_file'}
749 0 0 if (defined $prop->{'pid_file'} and -e $prop->{'pid_file'} and not $prop->{'_HUP'} and defined $prop->{'pid_file_unlink'})
753 0 0 unless unlink $prop->{'pid_file'}
756 0 12 if ($prop->{'_HUP'})
762 0 12 if $prop->{'no_exit_on_close'}
777 0 16 if $sock->NS_proto =~ /^UNIX/
789 0 0 unless $prop->{'ppid'}
798 0 3 unless $prop->{'children'} and scalar keys %{$$prop{'children'};}
802 4 0 if (kill 15, $pid or not kill(0, $pid))
816 0 0 unless defined $prop->{'children'} and scalar keys %{$$prop{'children'};}
817 0 0 unless $self->is_prefork
822 0 0 unless kill 1, $pid
846 0 0 unless $prop->{'_HUP'}[$i]->fdopen($fd, 'w')
860 0 0 if ($prop->{'leave_children_open_on_hup'} and scalar keys %{$$prop{'children'};})
896 0 93 unless $prop->{'log_level'}
897 25 68 if $level =~ /^\d+$/ and $level > $prop->{'log_level'}
898 0 68 if @therest
900 0 68 if ($prop->{'log_function'})
901 0 0 if eval { do { $prop->{'log_function'}->($level, $msg); 1 } }
903 0 0 if ($prop->{'log_class'} and $prop->{'log_class'}->can('handle_error')) { }
910 0 68 unless $level =~ /^\d+$/
924 0 68 if ($prop->{'log_file'}) { }
0 68 elsif ($prop->{'setsid'}) { }
949 552 296 if (not defined $prop->{$_}) { }
8 288 elsif (not ref $prop->{$_}) { }
975 106 27 unless $template and ref $template
976 0 0 unless ($_[2] or scalar keys %$template or $self->{'server'}{'_no_options'}++)
983 314 13 if ($args->[$i] =~ /^(?:--)?(\w+)(?:[=\ ](\S+))?$/ and exists $template->{$1})
987 311 3 unless (defined $val)
988 0 311 if ($i > $#$args or $args->[$i] and $args->[$i] =~ /^--\w+/) { }
993 0 35 if ref $val eq 'ARRAY' and @$val == 1 and ref $template->{$key} ne 'ARRAY'
997 274 40 unless ref $val
999 184 130 if (ref $template->{$key} eq 'ARRAY') { }
1000 142 42 unless (defined $previously_set{$key})
1003 12 172 if $previously_set{$key}
1004 35 137 ref $val eq 'ARRAY' ? :
1006 112 18 unless (defined $previously_set{$key})
1007 22 90 defined ${$$template{$key};} ? :
1009 25 105 if $previously_set{$key}
1010 0 105 if ref $val eq 'ARRAY'
1020 9 0 $file =~ m[^([\w\.\-\/\\\:]+)$] ? :
1021 0 9 unless (open my $fh, '<', $file)
1022 0 0 if $ENV{'BOUND_SOCKETS'}
1026 99 90 if $line =~ /^\s* ((?:--)?\w+) (?:\s*[=:]\s*|\s+) (\S+)/x
1042 0 4 unless exists $prop->{'children'}{$pid}
1045 1 3 if ($prop->{'child_communication'})
1046 1 0 if ($prop->{'children'}{$pid}{'sock'})
1062 0 0 unless kill $sig, $chld
1070 0 3 unless ref $ref
1071 0 3 if ref $ref ne 'ARRAY'
1072 3 0 unless @$ref
1077 0 0 if ($code) { }
1080 0 0 ref $SIG{$sig} eq 'CODE' ? :
1082 0 0 if $code
1091 0 2 $s->[1] ? :
1092 0 0 $s->[1] ? :
1093 3 4 $s->[1] ? :
1094 0 0 $s->[1] ? :
1095 0 0 $s->[1] ? :
1096 0 0 $s->[1] ? :
1097 0 0 $s->[1] ? :
1098 0 0 $s->[1] ? :
1099 0 0 $s->[1] ? :
1102 0 0 $s->[1] ? :