Hi,
After tons of debugging a case when I lost CGI POST variables I
discovered the following.
In perl 5.6.1, certain operations can cause references to filehandles to
loose TIE magic even when the filehandle is tied.
Witness.
use strict;
use IO::Scalar;
sub IO::Scalar::FILENO {};
my $scalar = "";
tie *STDIN, 'IO::Scalar', \$scalar;
fileno(STDIN);
my $fh = \*STDIN;
print $fh "HI";
print "---$scalar---\n";
Removing the fileno(STDIN), makes the above example work. This is fixed
in perl 5.8 to be, I don't know how far back it has effect I only tried
it under 5.6.1.
The result is that if a module does fileno(STDIN), or any of the other
potential ops (Anyone doing sv_setsv on a glob), any references to STDIN
will not be tied, however since CGI.pm reads STDIN for post data from a
reference to STDIN, and mod_perl makes it tied, suddenly post data will
not appear.
Worst case it will hang since it does a read( from /dev/null which is
what plain STDIN is under apache on linux).
The following patch corrects the problem without having any bad side
effects as far as I know.
--- CGI.pm~ Wed Apr 10 21:36:01 2002
+++ CGI.pm Tue May 14 11:34:22 2002
@@ -450,7 +450,7 @@
}
if ($meth eq 'POST') {
-
$self->read_from_client(\*STDIN,\$query_string,$content_length,0)
+
$self->read_from_client('STDIN',\$query_string,$content_length,0)
if $content_length > 0;
# Some people want to have their cake and eat it too!
# Uncomment this line to have the contents of the query string
Arthur
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
|