From: Andy Grundman Date: Wed, 16 May 2007 03:00:39 +0000 (+0000) Subject: Fixed issue where development server running in fork mode did not properly exit after... X-Git-Tag: 5.7099_04~185 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1b45d7e568761cc47399c1dffab8ce983d076b6f Fixed issue where development server running in fork mode did not properly exit after a write error. rt.cpan.org/Ticket/Display.html?id=27135 --- diff --git a/Changes b/Changes index 081b1a4..f106eec 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,9 @@ This file documents the revision history for Perl extension Catalyst. 5.7008 - Fixed a bug where Content-Length could be set to 0 if a filehandle object in $c->response->body did not report a size. + - Fixed issue where development server running in fork mode did not + properly exit after a write error. + (http://rt.cpan.org/Ticket/Display.html?id=27135) 5.7007 2007-03-13 14:18:00 - Many performance improvements by not using URI.pm: diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 20da4d5..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;