X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP.pm;h=f4fef51a6420014dc1e4197662a99fac8260baf5;hb=1b45d7e568761cc47399c1dffab8ce983d076b6f;hp=1bc26b1228c8dede14a6d6b278ce18f6fca9d4b1;hpb=b095458a5c35e1972b50d56b2570bdded48f8700;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 1bc26b1..f4fef51 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -276,17 +276,30 @@ sub run { unless ( uc($method) eq 'RESTART' ) { # Fork - if ( $options->{fork} ) { next if $pid = fork } + if ( $options->{fork} ) { + if ( $pid = fork ) { + DEBUG && warn "Forked child $pid\n"; + next; + } + } $self->_handler( $class, $port, $method, $uri, $protocol ); if ( my $error = delete $self->{_write_error} ) { DEBUG && warn "Write error: $error\n"; close Remote; - next LISTEN; + + if ( !defined $pid ) { + next LISTEN; + } } - $daemon->close if defined $pid; + if ( defined $pid ) { + # Child process, close connection and exit + DEBUG && warn "Child process exiting\n"; + $daemon->close; + exit; + } } else { my $sockdata = $self->_socket_data( \*Remote ); @@ -302,8 +315,6 @@ sub run { last; } } - - exit if defined $pid; } continue { close Remote; @@ -348,7 +359,7 @@ sub _handler { REQUEST: while (1) { my ( $path, $query_string ) = split /\?/, $uri, 2; - + # Initialize CGI environment local %ENV = ( PATH_INFO => $path || '',