perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Karasik <dmi...@karasik.eu.org>
Subject Re: [mp2] mod_perl closes apache's stdin and/or stdout
Date Tue, 09 Oct 2007 09:45:07 GMT
There's one thing, it might be important, and might be not.  The 'Alias'
setting didn't work on my setup, so instead of finding what's wrong with Alias,
I changed the config so the setup has two different but identical files perform
mod_perl and cgi requests.  So this section was (to be pedantic) different:

> +<IfModule mod_alias.c>
> +    Alias /stdin_override/mod_perl @ServerRoot@/cgi-bin/stdin.pl
> +    Alias /stdin_override/cgi      @ServerRoot@/cgi-bin/stdin.pl
> +</IfModule>
> +
> +<Location /stdin_override/mod_perl>
> +    SetHandler perl-script
> +    PerlResponseHandler ModPerl::Registry
> +    PerlOptions +ParseHeaders
> +    Options +ExecCGI
> +</Location>
> +
> +<Location /stdin_override/cgi>
> +    SetHandler cgi-script
> +    Options +ExecCGI
> +</Location>

Instead it was

+<Location /cgi-bin/stdin_mod_perl.pl>
+    SetHandler perl-script
+    PerlResponseHandler ModPerl::Registry
+    PerlOptions +ParseHeaders
+    Options +ExecCGI
+</Location>
+
+<Location /cgi-bin/stdin_cgi.pl>
+    SetHandler cgi-script
+    Options +ExecCGI
+</Location>

where stdin_cgi.pl and stdin_mod_perl.pl are copies of stdin.pl .
May I ask you to try that altered setup?

> Looking at modperl_io_perlio_restore_stdin however, isn't this where the
> real problem lies? It does restore Perl's stdin handle back to it's original
> state, but I don't see where/how that code would guarantee STDIN to re-acquire
> the same FD. Isn't that the bug ?

The problem is that modperl_io_perlio_restore_stdin() is called much later,
after possibly several further mod_perl requests are executed. I agree that
making sure to reassign FD to 0 (and stdout etc) would be a good idea, however,
by the time when the cgi script in question is being run, the FD 0 would stay
closed disregarding of whether modperl_io_perlio_restore_stdin() does the right
thing or not. 

> And avoiding the close() in the sugested patch would still need to undo
> the override in modperl_io_perlio_restore_stdin() to allow the real, underlying
> STDIN to be eventially closed, no ?

I do not understand that need to close FD 0 at all. All the overriding business
is done here so that PerlIO-level STDIN glob would be something else than FD 0,
which is fine. My point is that FD 0 is a shared resource within apache process
space, and it is neither mod_perl nor anyone else's business to close it.


-- 
Sincerely,
	Dmitry Karasik


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message