Branch Coverage

blib/lib/Monoceros/Server.pm
Criterion Covered Total %
branch 14 274 5.1


line true false branch
43 0 9 if (defined $ENV{'SERVER_STARTER_PORT'})
45 0 0 if ($hostport =~ /(.*):(\d+)/) { }
51 0 0 unless $listen_sock = 'IO::Socket::INET'->new('Proto', 'tcp')
54 0 0 unless $listen_sock->fdopen($fd, 'w')
60 2 16 if defined $args{$_}
92 0 9 defined $args{'max_readahead_reqs'} ? :
0 9 defined $args{'min_readahead_reqs'} ? :
0 9 defined $args{'min_reqs_per_child'} ? :
0 9 defined $args{'err_respawn_interval'} ? :
0 9 defined $listen_sock ? :
112 0 37 unless my(@pair) = &portable_socketpair()
121 0 9 unless my(@fdpass_sock) = &portable_socketpair()
137 3 6 if ($pid) { }
6 0 elsif (defined $pid) { }
156 0 0 unless (exists $self->{'sockets'}{$sockid})
164 0 0 unless (exists $self->{'sockets'}{$sockid})
167 0 0 if (_getpeername($self->{'sockets'}{$sockid}[1], my $addr) < 0)
175 0 0 unless ($ret)
176 0 0 if ($! == 11 or $! == 11 or $! == 4)
200 0 9 if $stats eq $prev_stats and @_
210 0 0 unless $buf
211 0 0 if ($buf =~ /total=(\d+)&/)
212 0 0 if $1 >= $self->{'max_keepalive_connection'}
238 0 0 unless $close_all
243 0 0 if $kid >= 0
254 0 0 if keys %{$$self{'sockets'};}
269 0 0 if ($self->{'sockets'}{$key}[4] == 0 and $self->{'sockets'}{$key}[3] == 0 and $time - $self->{'sockets'}{$key}[2] > $self->{'timeout'}) { }
0 0 elsif ($self->{'sockets'}{$key}[4] == 0 and $self->{'sockets'}{$key}[3] > 0 and $time - $self->{'sockets'}{$key}[2] > $self->{'keepalive_timeout'}) { }
290 0 0 unless $sock
300 0 0 if ($state->{'state'} eq 'cmd')
302 0 0 if (not defined $ret and $! == 4 || $! == 11 || $! == 11)
305 0 0 unless (defined $ret)
309 0 0 if (defined $buf and length $buf == 0)
313 0 0 if length $state->{'buf'} < 28
319 0 0 if ($method eq 'push') { }
0 0 elsif ($method eq 'keep') { }
0 0 elsif ($method eq 'clos') { }
325 0 0 if (exists $self->{'sockets'}{$sockid})
341 0 0 if ($state->{'state'} eq 'recv_fd')
343 0 0 if ($fd < 0 and $! == 4 || $! == 11 || $! == 11)
347 0 0 if ($fd <= 0)
390 0 0 if (defined $self->{'err_respawn_interval'})
398 0 0 if ($self->{'workers'}{$wid}{'running'} and $self->{'workers'}{$wid}{'running'} == $exit_pid)
407 0 0 unless ($self->{'workers'}{$wid}{'running'})
416 0 0 if (defined $next) { }
429 0 0 unless $next
431 0 0 if $wid == $next
438 0 0 unless open $self->{'stats_fh'}, '<', $self->{'stats_filename'}
461 0 0 if $self->{'term_received'} > 1
476 0 0 if $self->{'term_received'} and not $next_conn
479 0 0 if ($next_conn and $next_conn->{'buf'}) { }
486 0 0 if ($next_conn)
491 0 0 if (select($rfd, undef, undef, 1) > 0)
494 0 0 if (not defined $rfd or vec $rfd, $try_read_fd, 1)
495 0 0 if ($next_conn and fileno $next_conn->{'fh'} == $try_read_fd)
504 0 0 unless ($conn)
508 0 0 if ($conn and $next_conn and $conn != $next_conn)
512 0 0 if (not $conn and $next_conn)
519 0 0 unless $conn
542 0 0 if (exists $conn->{'buf'}) { }
548 0 0 if (not defined $ret and $! == 11 || $! == 11 || $! == 4) { }
0 0 elsif (defined $ret and $ret == 0) { }
555 0 0 unless $conn->{'direct'}
561 0 0 if $self->{'term_received'} or $self->{'stop_accept'}
568 0 0 unless ($keepalive)
571 0 0 unless $conn->{'direct'}
576 0 0 if (defined $pipelined_buf and length $pipelined_buf)
583 0 0 if ($conn->{'reqs'} < $max_readahead_reqs and $proc_req_count < $max_reqs_per_child)
609 0 0 if ($conn->{'direct'}) { }
614 0 0 if not defined $ret and $! != 11 and $! != 11 and $! != 4
628 0 0 if (fileno $sock == fileno $self->{'listen_sock'}) { }
0 0 elsif (fileno $sock == fileno $self->{'fdpass_sock'}[1]) { }
630 0 0 if (not $peer and ($! != 4 and $! != 11 and $! != 11 and $! != 29))
634 0 0 unless $peer
636 0 0 unless setsockopt $fh, 6, 1, 1
652 0 0 if ($fd < 0 and ($! != 4 and $! != 11 and $! != 11 and $! != 29))
655 0 0 if $fd <= 0
657 0 0 if (_getpeername($fd, $peer) < 0)
660 0 0 unless open my $fh, '<&=' . $fd
675 0 0 unless $conn
689 0 0 if (defined $prebuf) { }
698 0 0 $is_keepalive ? :
0 0 unless $rlen = $self->read_timeout($conn, \$buf, 131072 - length($buf), length $buf, $is_keepalive ? $self->{'keepalive_timeout'} : $self->{'timeout'})
702 0 0 if ($reqlen >= 0)
705 0 0 if ($use_keepalive)
706 0 0 if ($protocol eq 'HTTP/1.1') { }
707 0 0 if (my $c = $env->{'HTTP_CONNECTION'})
708 0 0 if $c =~ /^\s*close\s*/i
713 0 0 if (my $c = $env->{'HTTP_CONNECTION'}) { }
714 0 0 unless $c =~ /^\s*keep-alive\s*/i
720 0 0 if ($use_keepalive and $reqs <= 1)
726 0 0 if (my $cl = $env->{'CONTENT_LENGTH'}) { }
0 0 elsif ($chunked) { }
730 0 0 if (length $buf) { }
736 0 0 unless $self->read_timeout($conn, \$chunk, $cl, 0, $self->{'timeout'})
749 0 0 if (length $buf) { }
755 0 0 unless $self->read_timeout($conn, \$chunk, 65536, 0, $self->{'timeout'})
762 0 0 if ($chunk_len == 0) { }
0 0 elsif (length $chunk_buffer < $chunk_len + 2) { }
777 0 0 if ($buf =~ /^(?:GET|HEAD)/)
784 0 0 if ($env->{'HTTP_EXPECT'})
785 0 0 if ($env->{'HTTP_EXPECT'} eq '100-continue') { }
786 0 0 unless $self->write_all($conn, "HTTP/1.1 100 Continue\r\n\r\n")
797 0 0 if ($reqlen == -2) { }
0 0 elsif ($reqlen == -1) { }
805 0 0 if (ref $res eq 'ARRAY') { }
0 0 elsif (ref $res eq 'CODE') { }
831 0 0 if ($lck eq 'connection') { }
832 0 0 if $$use_keepalive_r and lc $v ne 'keep-alive'
839 0 0 unless (exists $send_headers{'server'})
842 0 0 unless (exists $send_headers{'date'})
848 0 0 if ($protocol eq 'HTTP/1.0') { }
0 0 elsif ($protocol eq 'HTTP/1.1') { }
849 0 0 if ($$use_keepalive_r)
850 0 0 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
0 0 elsif (not Plack::Util::status_with_no_entity_body($status_code) and defined(my $cl = Plack::Util::content_length($body))) { }
862 0 0 if $$use_keepalive_r
863 0 0 unless $$use_keepalive_r
866 0 0 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
0 0 elsif (not Plack::Util::status_with_no_entity_body($status_code)) { }
873 0 0 unless $$use_keepalive_r
880 0 0 if (defined $body and ref $body eq 'ARRAY' and @$body == 1 and length $body->[0] < 8192)
884 0 0 if ($use_chunked)
891 0 0 unless $len
895 0 0 unless $self->write_all($conn, join('', @lines), $self->{'timeout'})
897 0 0 if (defined $body) { }
900 0 0 ref $body eq 'ARRAY' ? :
904 0 0 unless ($failed)
907 0 0 if ($use_chunked)
909 0 0 unless $len
911 0 0 if ($body_count == 0)
917 0 0 unless $self->write_all($conn, $buf, $self->{'timeout'})
921 0 0 if $use_chunked and not $completed
926 0 0 if ($use_chunked)
928 0 0 unless $len
934 0 0 if $use_chunked
942 0 0 if (defined $min) { }