[Catalyst-commits] r6405 - in trunk/Catalyst-Runtime: . lib/Catalyst/Engine

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Wed May 16 04:00:40 GMT 2007


Author: andyg
Date: 2007-05-16 04:00:39 +0100 (Wed, 16 May 2007)
New Revision: 6405

Modified:
   trunk/Catalyst-Runtime/Changes
   trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm
Log:
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

Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes	2007-05-15 22:17:50 UTC (rev 6404)
+++ trunk/Catalyst-Runtime/Changes	2007-05-16 03:00:39 UTC (rev 6405)
@@ -3,6 +3,9 @@
 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:

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm	2007-05-15 22:17:50 UTC (rev 6404)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm	2007-05-16 03:00:39 UTC (rev 6405)
@@ -276,17 +276,30 @@
             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 @@
                     last;
                 }
             }
-
-            exit if defined $pid;
         }
         continue {
             close Remote;




More information about the Catalyst-commits mailing list