Author: sparky
Date: Mon May 10 00:39:49 2010
New Revision: 11409

Modified:
   toys/rsget.pl/RSGet/HTTPServer.pm
   toys/rsget.pl/RSGet/Main.pm
Log:
- don't fork in http server - trap sigpipe instead


Modified: toys/rsget.pl/RSGet/HTTPServer.pm
==============================================================================
--- toys/rsget.pl/RSGet/HTTPServer.pm   (original)
+++ toys/rsget.pl/RSGet/HTTPServer.pm   Mon May 10 00:39:49 2010
@@ -136,19 +136,13 @@
                $print .= "\r\n";
        }
 
-       my $kid = fork();
-       unless ( $kid ) {
-               # XXX: this is stupid, but I don't know what
-               # else to do if $client is closed already
-               print $client $print;
-               close $client;
-
-               # make sure no DESTROY blocks are called
-               require POSIX;
-               POSIX::_exit( 0 );
-       };
-
+       $RSGet::Main::sig_pipe = 0;
+       print $client $print;
+       if ( $RSGet::Main::sig_pipe ) {
+               warn "HTTP client closed on us !\n";
+       }
        close $client;
+
        return 1;
 }
 

Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm (original)
+++ toys/rsget.pl/RSGet/Main.pm Mon May 10 00:39:49 2010
@@ -54,6 +54,11 @@
 
 our %usettings;
 
+our $sig_pipe;
+$SIG{PIPE} = sub {
+       $sig_pipe = 1;
+};
+
 my $http = undef;
 sub init
 {
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to