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

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Fri Apr 4 17:08:20 BST 2008


Author: andyg
Date: 2008-04-04 17:08:19 +0100 (Fri, 04 Apr 2008)
New Revision: 7560

Modified:
   Catalyst-Runtime/5.70/trunk/Changes
   Catalyst-Runtime/5.70/trunk/lib/Catalyst/Engine/HTTP.pm
Log:
Patch from Ton Voon to fix bug in HTTP engine where the connection was not closed properly if the client disconnected before sending any headers

Modified: Catalyst-Runtime/5.70/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.70/trunk/Changes	2008-04-04 15:10:44 UTC (rev 7559)
+++ Catalyst-Runtime/5.70/trunk/Changes	2008-04-04 16:08:19 UTC (rev 7560)
@@ -3,6 +3,8 @@
 5.7013
         - Added test and updated docs for handling the Authorization header
           under mod_fastcgi/mod_cgi.
+        - Fixed bug in HTTP engine where the connection was not closed properly if the client disconnected
+          before sending any headers. (Ton Voon)
 
 5.7012  2007-12-16 23:44:00
         - Fix uri_for()'s and uri_with()'s handling of multibyte chars

Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/Engine/HTTP.pm	2008-04-04 15:10:44 UTC (rev 7559)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/Engine/HTTP.pm	2008-04-04 16:08:19 UTC (rev 7560)
@@ -263,14 +263,15 @@
             
             if ( !$self->_read_headers ) {
                 # Error reading, give up
+                close Remote;
                 next LISTEN;
             }
 
             my ( $method, $uri, $protocol ) = $self->_parse_request_line;
+            
+            next unless $method;
         
             DEBUG && warn "Parsed request: $method $uri $protocol\n";
-        
-            next unless $method;
 
             unless ( uc($method) eq 'RESTART' ) {
 
@@ -419,11 +420,16 @@
     
     while (1) {
         my $read = sysread Remote, my $buf, CHUNKSIZE;
-    
-        if ( !$read ) {
-            DEBUG && warn "EOF or error: $!\n";
+        
+        if ( !defined $read ) {
+            next if $! == EWOULDBLOCK;
+            DEBUG && warn "Error reading headers: $!\n";
             return;
         }
+        elsif ( $read == 0 ) {
+            DEBUG && warn "EOF\n";
+            return;
+        }
     
         DEBUG && warn "Read $read bytes\n";
         $self->{inputbuf} .= $buf;




More information about the Catalyst-commits mailing list