RE: CGI.pm params not being cleared?
-Original Message- From: Ken Williams [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 02, 2001 6:24 PM To: Geoffrey Young; 'Perrin Harkins ' Cc: '[EMAIL PROTECTED] ' Subject: RE: CGI.pm params not being cleared? Hi all, It doesn't much matter whether you're using stacked handlers or not, or pushing vs. replacing, because the $r-child_terminate method seems to simply call the C exit(0) function under certain conditions (Win32, old version of apache, anything else?). Not much chance of any further action if that's happening. just for clarity, the Apache.xs seems to say exit(0) if (old apache win32) current versions of Apache/mod_perl don't allow child_terminate at all for win32, if I'm reading the XS properly - there are two child_terminate() definitions, one that applies to old apaches and one for recent versions --Geoff Under normal conditions child_terminate() is just supposed to set: requests_this_child = ap_max_requests_per_child = 1; which shouldn't be a problem.
RE: CGI.pm params not being cleared?
OK, here's what I've found: If I install Apache::Sizelimit as a cleanup handler, neither Apache::SizeLimit::exit_if_too_big() or CGI::_reset_globals() are ever called. CGI::initialize_globals (which is what _reset_globals calls) is called once, at compile time for CGI.pm. When I removed Apache::Sizelimit as a cleanup handler, _reset_globals is called normally, and my original symptom disappears. If I put Apache::SizeLimit in as a FixupHandler CGI::_reset_globals() is called as expected, as is Apache::SizeLimit::exit_if_too_big() and my own FixupHandler's handler routine. Does this help? Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall -Original Message- From: Perrin Harkins [mailto:[EMAIL PROTECTED]] Sent: Monday, October 01, 2001 11:43 PM To: Alex Harper Cc: [EMAIL PROTECTED] Subject: Re: CGI.pm params not being cleared? Alex Harper wrote: I'm using a mod_perl 1.26 RPM I built using the RedHat RPM prep files and dropping in the 1.26 code. I believe it is built EVERYTHING=1. Apache::Status indicates all hooks are enabled, including: PerlStackedHandlers Enabled Okay. Would you mind putting some debugging statements in to find out what's being called? If you could put something in Apache::SizeLimit::exit_if_too_big() and something in CGI::_reset_globals(), maybe we can get to the bottom of this. - Perrin
RE: CGI.pm params not being cleared?
Hi all, It doesn't much matter whether you're using stacked handlers or not, or pushing vs. replacing, because the $r-child_terminate method seems to simply call the C exit(0) function under certain conditions (Win32, old version of apache, anything else?). Not much chance of any further action if that's happening. Under normal conditions child_terminate() is just supposed to set: requests_this_child = ap_max_requests_per_child = 1; which shouldn't be a problem. Geoffrey Young [EMAIL PROTECTED] wrote: -Original Message- From: Perrin Harkins To: Alex Harper Cc: Daniel; [EMAIL PROTECTED] Sent: 10/1/01 11:35 PM Subject: Re: CGI.pm params not being cleared? Alex Harper wrote: Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. Whoa! This could be bad. Apache::SizeLimit calls $r-post_connection(). Is that replacing existing cleanup handlers? I thought post_connection()/register_cleanup() pushed handlers on the stack rather than replacing them. you know, I just tested this this afternoon - register_cleanup does push handlers onto the stack. however, I have read a few bug reports in the archives that mention bugs along these lines - that sometimes the cleanup phase seems to allow only one handler. I know Randal mentioned it once, but IIRC it was 2+ years ago... FWIW --Geoff
Re: CGI.pm params not being cleared?
It doesn't much matter whether you're using stacked handlers or not, or pushing vs. replacing, because the $r-child_terminate method seems to simply call the C exit(0) function under certain conditions (Win32, old version of apache, anything else?). Not much chance of any further action if that's happening. What is this Win32 you speak of? I actually don't think this is much of an issue since people running on Win32 probably don't use SizeLimit (with one process, it's not such an issue), and it wouldn't work if they did since it doesn't know how to check process size there. Of course if someone out there needs it on Win32 and wants to contribute code to make it work, I'll take the patch. - Perrin
CGI.pm params not being cleared?
I'm sure this is a FAQ somewhere, but I'm not finding it... In our switch to mod_perl we're seeing two problems with CGI.pm (version 2.752). I'm uncertain if they are related or not. 1. Across multiple requests to a single script, the params are not cleared. The first params sent to that script (per Apache server) are wedged permanently. It doesn't seem to matter if the params came from GET or POST. 2. Despite precompiling CGI.pm using its compile method in our mod_perl startup, we constantly see warning for CGI.pm subroutine redefinitions (start_html, etc.) We precompile CGI.pm in our mod_perl startup as follows (from the guide): use CGI qw(-compile :all); In the script in question params are read like so: use CGI; $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { # Does something useful } Some of our modules also create (and destroy) CGI objects, but none of them are global, and I can't see any way for the script to be getting confused with a module's copy (the script itself does not user those modules, though they are precompiled during mod_perl startup). Obviously I must be doing something wrong... Any suggestions? Thanks for any assistance, Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall
Re: CGI.pm params not being cleared?
On Mon, 1 Oct 2001, Alex Harper wrote: Date: Mon, 1 Oct 2001 16:16:34 -0500 From: Alex Harper [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: CGI.pm params not being cleared? I'm sure this is a FAQ somewhere, but I'm not finding it... In our switch to mod_perl we're seeing two problems with CGI.pm (version 2.752). I'm uncertain if they are related or not. 1. Across multiple requests to a single script, the params are not cleared. The first params sent to that script (per Apache server) are wedged permanently. It doesn't seem to matter if the params came from GET or POST. 2. Despite precompiling CGI.pm using its compile method in our mod_perl startup, we constantly see warning for CGI.pm subroutine redefinitions (start_html, etc.) We precompile CGI.pm in our mod_perl startup as follows (from the guide): use CGI qw(-compile :all); In the script in question params are read like so: use CGI; $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { # Does something useful } Perhaps you ought to declare $cgi with a my? Some of our modules also create (and destroy) CGI objects, but none of them are global, and I can't see any way for the script to be getting confused with a module's copy (the script itself does not user those modules, though they are precompiled during mod_perl startup). Obviously I must be doing something wrong... Any suggestions? Well, despite CGI.pm's overall usefulness, is there any reason you don't use Apache::Request? It's definitely faster. ky
RE: CGI.pm params not being cleared?
I actually forgot to mention that we had tried it with my $cgi and $cgi. Neither worked. As for switching to Apache::Request, no can do. We need to maintain mod_cgi compatibility for at least a few more months. Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall -Original Message- From: Ken Y. Clark [mailto:[EMAIL PROTECTED]] Sent: Monday, October 01, 2001 4:25 PM To: Alex Harper Cc: [EMAIL PROTECTED] Subject: Re: CGI.pm params not being cleared? On Mon, 1 Oct 2001, Alex Harper wrote: Date: Mon, 1 Oct 2001 16:16:34 -0500 From: Alex Harper [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: CGI.pm params not being cleared? I'm sure this is a FAQ somewhere, but I'm not finding it... In our switch to mod_perl we're seeing two problems with CGI.pm (version 2.752). I'm uncertain if they are related or not. 1. Across multiple requests to a single script, the params are not cleared. The first params sent to that script (per Apache server) are wedged permanently. It doesn't seem to matter if the params came from GET or POST. 2. Despite precompiling CGI.pm using its compile method in our mod_perl startup, we constantly see warning for CGI.pm subroutine redefinitions (start_html, etc.) We precompile CGI.pm in our mod_perl startup as follows (from the guide): use CGI qw(-compile :all); In the script in question params are read like so: use CGI; $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { # Does something useful } Perhaps you ought to declare $cgi with a my? Some of our modules also create (and destroy) CGI objects, but none of them are global, and I can't see any way for the script to be getting confused with a module's copy (the script itself does not user those modules, though they are precompiled during mod_perl startup). Obviously I must be doing something wrong... Any suggestions? Well, despite CGI.pm's overall usefulness, is there any reason you don't use Apache::Request? It's definitely faster. ky
Re: CGI.pm params not being cleared?
Make sure you're not doing: use CGI; my $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { do_whatever_without_passing_cgi(); } elsif ($cgi-param(dataaction) eq passcgi) { pass_it_cgi($cgi); } sub do_whatever_without_passing_cgi { #using original copy of $cgi object for life here my $notshared = $cgi-param(crufty); print Crufty $notshared variable\n; } sub pass_it_cgi { my $cgi = shift; my $goodvar= $cgi-param('notcrufty'); print Passed it and got a $goodvar\n; } In the script in question params are read like so: use CGI; $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { # Does something useful HTH, check the guide: http://perl.apache.org/guide/porting.html. -- -- Daniel Bohling NewsFactor Network
RE: CGI.pm params not being cleared?
Thanks, I looked and we're not. Here's the simplest case: use CGI; my $cgi = new CGI; my @params = $cgi-Vars(); print $cgi-header(-type = 'text/html'); print $cgi-start_html(); print Process: $$BR\n; print Query String:BR\n; print $ENV{QUERY_STRING} . BR\n; print Params:BR\n; print join(BR\n, @params) . BR\n; print $cgi-end_html(); I push some arbitrary params (theparam=try1, etc.) in the URL and get back: Process: 18860 Query String: theparam=try2 Params: theparam try1 Note the mismatch between the query string and the params. Apache is running just 2 servers (StartServers 2) and I removed the CGI.pm precompile from the mod_perl startup. Any other suggestions? I'm feeling a bit desperate... Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall
Re: CGI.pm params not being cleared?
Odd, checking into my version CGI.pm (which I dont use), it cleans up it's own globals by installing a cleanup handler: Apache-request-register_cleanup(\CGI::_reset_globals); so either your version of CGI.pm is broken or your mod_perl was somehow compiled without PERL_CLEANUP. Alex Harper wrote: Thanks, I looked and we're not. Here's the simplest case: use CGI; my $cgi = new CGI; my @params = $cgi-Vars(); print $cgi-header(-type = 'text/html'); print $cgi-start_html(); print Process: $$BR\n; print Query String:BR\n; print $ENV{QUERY_STRING} . BR\n; print Params:BR\n; print join(BR\n, @params) . BR\n; print $cgi-end_html(); I push some arbitrary params (theparam=try1, etc.) in the URL and get back: Process: 18860 Query String: theparam=try2 Params: theparam try1 Note the mismatch between the query string and the params. Apache is running just 2 servers (StartServers 2) and I removed the CGI.pm precompile from the mod_perl startup. Any other suggestions? I'm feeling a bit desperate... Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall -- -- Daniel Bohling NewsFactor Network
RE: CGI.pm params not being cleared?
Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. This leads me to some questions: 1. If I declare handler modules in my http.conf are these pushed onto the StackedHandlers, or does it override any prior handlers? i.e if my httpd.conf contains: PerlFixupHandler MyLibs::Fixup PerlFixupHandler Apache::Sizelimit will both handlers be called? Or must I do: PerlFixupHandler MyLibs::Fixup Apache::Sizelimit 2. If I declare a handler in my http.conf and a loaded module stacks a second handler (like CGI does) do both get called? (apparently not) 3. Where is the best place to hook Apache::Sizelimit so that it is handled post-request (and hopefully does not step on any other toes) since stacked handlers seem to fail (at least in this case). Daniel, thanks for pointing me in the right direction! Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall -Original Message- From: Daniel [mailto:[EMAIL PROTECTED]] Sent: Monday, October 01, 2001 6:35 PM To: Alex Harper; [EMAIL PROTECTED] Subject: Re: CGI.pm params not being cleared? Odd, checking into my version CGI.pm (which I dont use), it cleans up it's own globals by installing a cleanup handler: Apache-request-register_cleanup(\CGI::_reset_globals); so either your version of CGI.pm is broken or your mod_perl was somehow compiled without PERL_CLEANUP. Alex Harper wrote: Thanks, I looked and we're not. Here's the simplest case: use CGI; my $cgi = new CGI; my @params = $cgi-Vars(); print $cgi-header(-type = 'text/html'); print $cgi-start_html(); print Process: $$BR\n; print Query String:BR\n; print $ENV{QUERY_STRING} . BR\n; print Params:BR\n; print join(BR\n, @params) . BR\n; print $cgi-end_html(); I push some arbitrary params (theparam=try1, etc.) in the URL and get back: Process: 18860 Query String: theparam=try2 Params: theparam try1 Note the mismatch between the query string and the params. Apache is running just 2 servers (StartServers 2) and I removed the CGI.pm precompile from the mod_perl startup. Any other suggestions? I'm feeling a bit desperate... Alex -- Alex Harper Configuration Management [EMAIL PROTECTED] Use whatever you think of first -- Larry Wall -- -- Daniel Bohling NewsFactor Network
Re: CGI.pm params not being cleared?
Alex Harper wrote: Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. Whoa! This could be bad. Apache::SizeLimit calls $r-post_connection(). Is that replacing existing cleanup handlers? I thought post_connection()/register_cleanup() pushed handlers on the stack rather than replacing them. - Perrin
RE: CGI.pm params not being cleared?
-Original Message- From: Perrin Harkins To: Alex Harper Cc: Daniel; [EMAIL PROTECTED] Sent: 10/1/01 11:35 PM Subject: Re: CGI.pm params not being cleared? Alex Harper wrote: Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. Whoa! This could be bad. Apache::SizeLimit calls $r-post_connection(). Is that replacing existing cleanup handlers? I thought post_connection()/register_cleanup() pushed handlers on the stack rather than replacing them. you know, I just tested this this afternoon - register_cleanup does push handlers onto the stack. however, I have read a few bug reports in the archives that mention bugs along these lines - that sometimes the cleanup phase seems to allow only one handler. I know Randal mentioned it once, but IIRC it was 2+ years ago... FWIW --Geoff
Re: CGI.pm params not being cleared?
Did you compile mod_perl with PERL_STACKED_HANDLERS? Perrin Harkins wrote: Alex Harper wrote: Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. Whoa! This could be bad. Apache::SizeLimit calls $r-post_connection(). Is that replacing existing cleanup handlers? I thought post_connection()/register_cleanup() pushed handlers on the stack rather than replacing them. - Perrin -- -- Daniel Bohling NewsFactor Network
RE: CGI.pm params not being cleared?
I'm using a mod_perl 1.26 RPM I built using the RedHat RPM prep files and dropping in the 1.26 code. I believe it is built EVERYTHING=1. Apache::Status indicates all hooks are enabled, including: PerlStackedHandlers Enabled Alex -- From: Daniel Sent: Monday, October 1, 2001 7:42 PM To: Perrin Harkins Cc: Alex Harper; [EMAIL PROTECTED] Subject: Re: CGI.pm params not being cleared? Did you compile mod_perl with PERL_STACKED_HANDLERS? Perrin Harkins wrote: Alex Harper wrote: Aha! That's where the problem lies. I had recently added: PerlCleanupHandler +Apache::Sizelimit to my httpd.conf. I placed it there so the sizelimit would be enforced post-request. Removing the line fixed my problem. Whoa! This could be bad. Apache::SizeLimit calls $r-post_connection(). Is that replacing existing cleanup handlers? I thought post_connection()/register_cleanup() pushed handlers on the stack rather than replacing them. - Perrin -- -- Daniel Bohling NewsFactor Network
Re: CGI.pm params not being cleared?
Alex Harper wrote: I'm using a mod_perl 1.26 RPM I built using the RedHat RPM prep files and dropping in the 1.26 code. I believe it is built EVERYTHING=1. Apache::Status indicates all hooks are enabled, including: PerlStackedHandlers Enabled Okay. Would you mind putting some debugging statements in to find out what's being called? If you could put something in Apache::SizeLimit::exit_if_too_big() and something in CGI::_reset_globals(), maybe we can get to the bottom of this. - Perrin