add LastCall method
skimo [Thu, 20 Sep 2001 12:00:23 +0000 (12:00 +0000)]
perl/FCGI.PL
perl/FCGI.XL

index 94008ed..23cedb9 100644 (file)
@@ -6,7 +6,7 @@ open OUT, ">FCGI.pm";
 
 print "Generating FCGI.pm\n";
 print OUT <<'EOP';
-# $Id: FCGI.PL,v 1.29 2001/09/20 11:07:36 skimo Exp $
+# $Id: FCGI.PL,v 1.30 2001/09/20 12:00:23 skimo Exp $
 
 package FCGI;
 
@@ -83,6 +83,7 @@ sub RequestX {
        env => shift,
        socket => shift,
        flags => shift,
+       last => 0,
     };
     open $self->{listen_sock}, "<&=0";
     bless $self, "FCGI";
@@ -101,7 +102,7 @@ sub Accept {
     }
     $req->Finish();
     $req->{socket} = gensym();
-    if (!accept($req->{socket}, $req->{listen_sock})) {
+    if ($req->{last} || !accept($req->{socket}, $req->{listen_sock})) {
        $req->{error} = "accept";
        return -1;
     }
@@ -169,6 +170,10 @@ sub Finish {
     $req->{accepted} = 0;
 }
 
+sub LastCall {
+    shift->{last} = 1;
+}
+
 sub DESTROY {
     shift->Finish();
 }
@@ -520,6 +525,14 @@ Temporarily detaches filehandles on an accepted connection.
 
 Re-attaches filehandles on an accepted connection.
 
+=item $req->LastCall()
+
+Tells the library not to accept any more requests on this handle.
+It should be safe to call this method from signal handlers.
+
+Note that this method is still experimental and everything
+about it, including its name, is subject to change.
+
 =item $env = $req->GetEnvironment()
 
 Returns the environment parameter passed to FCGI::Request.
index 7822df1..2eb7a4d 100644 (file)
@@ -12,7 +12,7 @@ unless ($] >= 5.005) {
 print OUT while <DATA>;
 close OUT;
 __END__
-/* $Id: FCGI.XL,v 1.5 2001/09/20 11:03:41 skimo Exp $ */
+/* $Id: FCGI.XL,v 1.6 2001/09/20 12:00:24 skimo Exp $ */
 
 #include "EXTERN.h"
 #include "perl.h"
@@ -456,7 +456,6 @@ FCGI_IsFastCGI(request)
 
 void
 Detach(request)
-
     FCGI    request;
 
     PROTOTYPE: $
@@ -467,7 +466,6 @@ Detach(request)
 
 void
 Attach(request)
-
     FCGI    request;
 
     PROTOTYPE: $
@@ -476,6 +474,14 @@ Attach(request)
     if (request->accepted && !request->bound)
        FCGI_Bind(request);
 
+void
+LastCall(request)
+    FCGI    request;
+
+    PROTOTYPE: $
+
+    CODE:
+    FCGX_ShutdownPending();
 
 int
 FCGI_StartFilterData(request)