File Coverage

blib/lib/Plack/Handler/Feersum/SS.pm
Criterion Covered Total %
statement 24 41 58.5
branch 0 16 0.0
condition n/a
subroutine 8 9 88.8
pod n/a
total 32 66 48.4


line stmt bran cond sub pod time code
1             # ABSTRACT: Server::Starter adapter for Feersum Plack handler
2             package Plack::Handler::Feersum::SS;
3             $Plack::Handler::Feersum::SS::VERSION = '0.01';
4 1     1   70408 use strict;
  1         3  
  1         31  
5 1     1   5 use warnings;
  1         2  
  1         27  
6 1     1   6 use base 'Plack::Handler::Feersum';
  1         3  
  1         572  
7 1     1   39663 use Feersum;
  1         3  
  1         23  
8 1     1   593 use Server::Starter 'server_ports';
  1         7798  
  1         62  
9 1     1   8 use Carp 'croak';
  1         2  
  1         46  
10 1     1   6 use Symbol 'geniosym';
  1         2  
  1         52  
11 1     1   6 use Fcntl qw'F_GETFL F_SETFL O_NONBLOCK';
  1         2  
  1         241  
12              
13             # redefining (origins: Feersum::Runner, Plack::Handler::Feersum)
14             sub _prepare {
15 0     0     my $self = shift;
16 0 0         delete $self->{quiet} if delete $self->{verbose};
17 0           my %ports = %{server_ports()};
  0            
18 0 0         croak "Feersum doesn't support none/multiple listen directives yet" unless %ports == 1;
19 0           my ($port, $fd) = each %ports;
20 0 0         open(my $sock = geniosym, "<&=", $fd) || croak $!;
21 0 0         my $flags = fcntl($sock, F_GETFL, 0) or croak $!;
22 0 0         fcntl($sock, F_SETFL, $flags | O_NONBLOCK) || croak $!;
23 0 0         print "Feersum [$$] listening on $port fd=$fd\n" unless $self->{quiet};
24 0           $self->{sock} = $sock;
25 0           my $f = $self->{endjinn} = Feersum->endjinn;
26 0           $f->use_socket($sock);
27 0 0         if ($self->{options}) {
28 0           $self->{pre_fork} = delete $self->{options}{pre_fork};
29             }
30 0 0         $self->{server_ready}->($self) if $self->{server_ready};
31 0           return;
32             }
33              
34             1;