[Rt-commit] r3830 - in HTTP-Server-Simple: . lib/HTTP/Server

jesse at bestpractical.com jesse at bestpractical.com
Mon Sep 5 14:10:46 EDT 2005


Author: jesse
Date: Mon Sep  5 14:10:45 2005
New Revision: 3830

Modified:
   HTTP-Server-Simple/   (props changed)
   HTTP-Server-Simple/Changes
   HTTP-Server-Simple/MANIFEST
   HTTP-Server-Simple/META.yml
   HTTP-Server-Simple/SIGNATURE
   HTTP-Server-Simple/lib/HTTP/Server/Simple.pm
Log:
 r15369 at hualien:  jesse | 2005-09-04 17:46:05 -0400
 * Cleanup to properly handle SIGPIPE, like when the user closes the connection on us


Modified: HTTP-Server-Simple/Changes
==============================================================================
--- HTTP-Server-Simple/Changes	(original)
+++ HTTP-Server-Simple/Changes	Mon Sep  5 14:10:45 2005
@@ -1,5 +1,7 @@
 
   Split out HTTP::Server::Simple::CGI::Environment to support non-CGI.pm CGIs
+  Ignore SIGPIPE
+
 
 0.13 Tue Aug  9 21:25:20 EDT 2005
 

Modified: HTTP-Server-Simple/MANIFEST
==============================================================================
--- HTTP-Server-Simple/MANIFEST	(original)
+++ HTTP-Server-Simple/MANIFEST	Mon Sep  5 14:10:45 2005
@@ -9,6 +9,7 @@
 inc/Module/Install/WriteAll.pm
 lib/HTTP/Server/Simple.pm
 lib/HTTP/Server/Simple/CGI.pm
+lib/HTTP/Server/Simple/CGI/Environment.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml

Modified: HTTP-Server-Simple/META.yml
==============================================================================
--- HTTP-Server-Simple/META.yml	(original)
+++ HTTP-Server-Simple/META.yml	Mon Sep  5 14:10:45 2005
@@ -1,5 +1,5 @@
 name: HTTP-Server-Simple
-version: 0.13
+version: 0.14_02
 license: perl
 distribution_type: module
 requires:

Modified: HTTP-Server-Simple/SIGNATURE
==============================================================================
--- HTTP-Server-Simple/SIGNATURE	(original)
+++ HTTP-Server-Simple/SIGNATURE	Mon Sep  5 14:10:45 2005
@@ -14,8 +14,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 de608e218003f26fbd0fee7d79ad8b78fe2715f3 Changes
-SHA1 74092110d280de0961a26025021bb987d345dabc MANIFEST
+SHA1 33766e77267ce32581d8a04c0fd168d511c38aa8 Changes
+SHA1 0ac508c50476dcc2bf8fe3094cb341425291e1ee MANIFEST
 SHA1 0aa0b675ec98b4fcc9eb3d8ca3533a17ca72ff57 META.yml
 SHA1 490f3fd115e09cb05b725580e5ed5cdd58241049 Makefile.PL
 SHA1 ed0c107672daac3bc9e266876666e1059dbe44b7 README
@@ -28,8 +28,9 @@
 SHA1 e448c6dc5351ef425e3f8bdbeb642409120bc3ca inc/Module/Install/Metadata.pm
 SHA1 134de6ff2f762873b6a1af950dd53f8e0a801d73 inc/Module/Install/Win32.pm
 SHA1 1ec06df292af7f652d33db6129e9e4c7cc8b5095 inc/Module/Install/WriteAll.pm
-SHA1 bac22d5a4df86809a430790b5745c22398ad15aa lib/HTTP/Server/Simple.pm
-SHA1 f8717b83bec75c3b7dc7904b14823bf605b77f99 lib/HTTP/Server/Simple/CGI.pm
+SHA1 d82eb06c79379742662cf4eefc96da8dc5eeae41 lib/HTTP/Server/Simple.pm
+SHA1 45d68d9c4b821a6376f35898aa860c1229f61d16 lib/HTTP/Server/Simple/CGI.pm
+SHA1 94094b43c94eddcdf24ca613a86ccce11874f67b lib/HTTP/Server/Simple/CGI/Environment.pm
 SHA1 db064af54cab345a71daec576e32e64b8fb1033d t/00smoke.t
 SHA1 9e68bffc26b5a42e2785ec68c3bf6fe45d6bb6da t/01live.t
 SHA1 aca95653cfce68912e08c57b3a4566207e2f99b3 t/02pod.t
@@ -38,7 +39,7 @@
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.1 (GNU/Linux)
 
-iD8DBQFC+VetEi9d9xCOQEYRApnVAJ48RyxwPVlML9Y7cMI8VegRZKDu8ACeLQx+
-/rB4JjYI87p33E7PpnYxSZk=
-=XmHA
+iD8DBQFDGGPzEi9d9xCOQEYRAo3HAJ4h9HEfWI47aCws/Im3Zi/dIL5gYwCaAqR7
+2YIKQ+CQj+HFJVbVWUZbzCU=
+=dxhv
 -----END PGP SIGNATURE-----

Modified: HTTP-Server-Simple/lib/HTTP/Server/Simple.pm
==============================================================================
--- HTTP-Server-Simple/lib/HTTP/Server/Simple.pm	(original)
+++ HTTP-Server-Simple/lib/HTTP/Server/Simple.pm	Mon Sep  5 14:10:45 2005
@@ -5,7 +5,7 @@
 use Socket;
 use Carp;
 
-our $VERSION = '0.13';
+our $VERSION = '0.14_02';
 
 =head1 NAME
 
@@ -60,12 +60,11 @@
 
 # Handle SIGHUP
 
+                             
+                             
 local $SIG{CHLD} = 'IGNORE'; # reap child processes
 local $SIG{HUP} = sub {
-    # on a "kill -HUP", we first close our socket handles.
-    close Remote;
     close HTTPDaemon;
-
     # and then, on systems implementing fork(), we make sure
     # we are running with a new pid, so another -HUP will still
     # work on the new process.
@@ -202,14 +201,19 @@
         $self->print_banner;
 
         while (1) {
-            for ( ; accept( Remote, HTTPDaemon ) ; close Remote ) {
-                $self->stdio_handle(\*Remote);
+            local $SIG{PIPE} = 'IGNORE'; # If we don't ignore SIGPIPE, a 
+                                      # client closing the connection before we 
+                                      # finish sending will cause the server to exit
+            while ( accept( my $remote, HTTPDaemon )) {
+                $self->stdio_handle($remote);
                 $self->accept_hook if $self->can("accept_hook");
 
                 *STDIN  = $self->stdin_handle();
                 *STDOUT = $self->stdout_handle();
-		select STDOUT; # required for Recorder
+		select STDOUT; # required for HTTP::Server::Simple::Recorder
+                               # XXX TODO glasser: why?
                 $pkg->process_request;
+                close $remote;
             }
         }    
     }
@@ -221,6 +225,7 @@
     # Create a callback closure that is invoked for each incoming request;
     # the $self above is bound into the closure.
     sub {
+
         $self->stdio_handle(*STDIN) unless $self->stdio_handle;
 
         # Default to unencoded, raw data out.
@@ -278,6 +283,7 @@
 
         $self->post_setup_hook if $self->can("post_setup_hook");
 
+
         $self->handler;
     }
 }


More information about the Rt-commit mailing list