Item1823: Using FastCGIEngineContrib together with CODE_ENSCRIPT results in an error when viewing the topic
Priority: Normal
Current State: No Action Required
Released In:
Target Release: n/a
Configure the system to use
FastCGIEngineContrib with
mod_fcgi
or
mod_fastcgi
. Create a test topic with this content:
%CODE_ENSCRIPT{ lang="bash" }% #!/bin/bash
%ENDCODE%
When trying to view this topic the following error shows up in the browser window::
Foswiki detected an internal error - please check your Foswiki logs and webserver logs for more information.
Can't locate object method "FILENO" via package "FCGI::Stream"
and in apache error log:
[Fri Jul 10 18:31:40 2009] [warn] mod_fcgid: stderr: Can't locate object method "FILENO" via package "FCGI::Stream" at /usr/share/perl5/IPC/Run.pm line 1118.
Encountered on Debian Lenny with apache2.
--
IngoKappler - 10 Jul 2009
Thanks for the bug report. Hopefully I will have time at the weekend to set up a Fast CGI environment and take a look.
Perhaps if I can remove the dependency on IPC::Run (
Item8077) then this will no longer be an issue.
--
AndrewJones - 13 Jul 2009
I cannot reproduce this in my environment. What version of IPC::Run are you using? I am using 0.80.
--
AndrewJones - 07 Aug 2009
On my Debian is this installed:
libipc-run-perl 0.80-2
. There are also some other package named
libipc-XXXXX-perl
which are all not installed on my system.
I just retested and could still reproduce the issue:
Fcgi_error.png
No_issue_with_mod_perl.png
Could it be helpful to look at the related apache-foswiki configuration? I could make it available to you.
--
IngoKappler - 07 Aug 2009
I get the same error when using BDB under FCGI. Here's a link that says that this is an FCGI problem (patch included):
http://www.mail-archive.com/ports%40openbsd.org/msg16948.html
--- /usr/lib/perl5/FCGI.pm.orig 2009-08-11 19:16:38.000000000 +0200
+++ /usr/lib/perl5/FCGI.pm 2009-08-11 19:16:41.000000000 +0200
@@ -134,7 +134,7 @@
# Apparently some use fileno to determine if a filehandle is open,
# so we might want to return a defined, but meaningless value.
# An alternative would be to return the fcgi stream fd.
-# sub FILENO { -2 }
+sub FILENO { -2 }
1;
--
MichaelDaum - 11 Aug 2009
Here's a patch that monkey patches FCGI::Stream via
FastCGIEngineContrib:
--- lib/Foswiki/Engine/FastCGI.pm (revision 4640)
+++ lib/Foswiki/Engine/FastCGI.pm (working copy)
@@ -56,6 +56,13 @@
*VERSION = \$Foswiki::Contrib::FastCGIEngineContrib::VERSION;
*RELEASE = \$Foswiki::Contrib::FastCGIEngineContrib::RELEASE;
+# hack for perl libraries that use FILENO, alternatively patch FCGI.pm
+BEGIN {
+ sub FILENO { -2 }
+ *FCGI::Stream::FILENO = \&FILENO;
+}
+
+
our $hupRecieved = 0;
Gilmar, do you think this is worth adding to
FastCGIEngineContrib?
--
MichaelDaum - 11 Aug 2009
Reading
FCGI code, I think that a semantically correct solution would be (untested):
BEGIN {
*FCGI::Stream::FILENO = sub {
my ($stream) = @_;
return fileno ${ $stream->{in} } if $stream->{type} == FCGI::FCGI_STDIN;
return fileno ${ $stream->{out} }
if $stream->{type} == FCGI::FCGI_STDOUT;
return fileno ${ $stream->{err} }
if $stream->{type} == FCGI::FCGI_STDERR;
};
}
But maybe this would cause more problems than it'd solve things... I think it needs careful tests to map side effects. The goal is: if a code calls
fileno
to figure out if the handle is open, any meaningless defined value is enough. But if the intention is to read/write to the handle directly (or to build another handle with
dup
), then it needs special attention. I don't know how Perl deals with this situation and it's what need to be tested.
--
GilmarSantosJr - 14 Aug 2009
This gets more and more important as the only reasonable Foswiki PageCache backend is BDB... which only works if we solve
FILENO
in FCGI.
--
MichaelDaum - 21 Aug 2009
I want to see more cases where
FILENO
is required... but it's interesting to add the first workaround suggested to get things working.
How can I reproduce the issue with BDB?
--
GilmarSantosJr - 23 Aug 2009
Go to
configure
, enable the PageCache and enable the BDB backend.
--
MichaelDaum - 24 Aug 2009
It seems newer fcgi now does implement a FILENO. So hacking it in via
FastCGIEngineContrib isnt necessary anymore. Infact, I get a "redefined" error with above patch.
--
MichaelDaum - 06 Jul 2010