use Config;
+use ExtUtils::MakeMaker;
do 'FCGI.cfg' or die "no FCGI.cfg";
print "Generating FCGI.pm\n";
print OUT <<'EOP';
-# $Id: FCGI.PL,v 1.23 2001/03/27 11:49:11 skimo Exp $
+# $Id: FCGI.PL,v 1.34 2001/10/04 08:04:16 skimo Exp $
package FCGI;
);
-$VERSION = '0.60';
-
EOP
+print OUT '$VERSION = '.MM->parse_version('version.pm').";\n\n";
+
print OUT "bootstrap FCGI;\n" unless ($pure);
print OUT <<'EOP' if ($pure);
AUTHORIZER, "AUTHORIZER",
FILTER, "FILTER",
);
+
+# This only works on Unix; anyone familiar with Windows is welcome
+# to give a hand here
sub IsFastCGI {
my ($req) = @_;
$req->{isfastcgi} =
return $req->{isfastcgi};
}
+sub GetEnvironment {
+ return shift->{'env'};
+}
+
sub read_nv_len {
my ($stream) = @_;
my $buf;
return undef unless read $stream, $buf, 1, 0;
my ($len) = unpack("C", $buf);
if ($len & 0x80) {
+ $buf = pack("C", $len & 0x7F);
return undef unless read $stream, $buf, 3, 1;
$len = unpack("N", $buf);
}
env => shift,
socket => shift,
flags => shift,
+ last => 0,
};
open $self->{listen_sock}, "<&=0";
bless $self, "FCGI";
}
$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;
}
$req->{accepted} = 0;
}
+sub LastCall {
+ shift->{last} = 1;
+}
+
sub DESTROY {
shift->Finish();
}
*FAIL_ACCEPT_ON_INTR = sub() { 1 };
-sub Request(;***$$$) {
+sub Request(;***$*$) {
my @defaults = (\*STDIN, \*STDOUT, \*STDERR, \%ENV, 0, 0);
+ $_[4] = fileno($_[4]) if defined($_[4]) && defined(fileno($_[4]));
splice @defaults,0,@_,@_;
RequestX(@defaults);
}
For the moment, it's the file descriptor of the socket
that should be passed. This may change in the future.
+You should only use your own socket if your program
+is not started by a process manager such as mod_fastcgi
+(except for the FastCgiExternalServer case) or cgi-fcgi.
+If you use the option, you have to let your FastCGI
+server know which port (and possibly server) your program
+is listening on.
+See remote.pl for an example.
+
=item flags (default: 0)
Possible values:
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.