POST and GET and getting multiple unsynced requests

2001-10-07 Thread Mark Maunder

Hi all,

I've written a web app as a single mod_perl handler. I started writing
my forms so they would do a POST and GET simultaneously. I did this by
making the form method=POST  action="/job_details?job=65" for example.
Now I notice that IE and Netscape do a POST and GET request every time
the form is submitted (so I'm logging two requests for the same URI and
Mime type for each form submission. The first is GET and the second is
POST). My problem is that the data returned to the browser is from the
GET request. The page that is generated has content that is affected by
the POSTed data, but this is only visible on a refresh of the same page.

I've done tests with Netscape and IE. I consistently have this problem
with Netscape, and with IE it works most of the time, but approximatelly
every 20 requests, I'll get a page that is generated from the GET data,
not the POSTed data.

I've included a source snippit from my handler below. If anyone has seen
this before, I'd appreciate any help! (I scoured the guide and archive.
I'm really sorry if I missed it!)

--snip--
sub handler
{
my $r = Apache::Request->new(shift @_);
$r->log_error("Request being handled: " . $r->content_type() . "
- " . $r->uri() . " - " . $r->method());
#We dont want to handle image, CSS or javascript requests
if($r->content_type() =~ m/(^image|^text\/css|javascript)/)
{
return DECLINED;
}
my $dbh = FUtil::connect_database();
--end snippet--

And the error log shows:
[Sun Oct  7 23:05:38 2001] [error] Request being handled:  -
/job_details - GET
[Sun Oct  7 23:05:38 2001] [error] Request being handled:  -
/job_details - POST
[Sun Oct  7 23:05:38 2001] [error] Request being handled: text/css -
/style.css - GET
[Sun Oct  7 23:05:38 2001] [error] Request being handled:
application/x-javascript - /js.js - GET

The form HTML tag that did this was:
http://www.freeusall.com/job_details?job=61"; method=POST
name="hotlist_form_jd_61">
This is doing a POST and GET.




Re: piece of code in mod_perl guide

2001-10-07 Thread pascal barbedor

> >
> >
> [  ]
> > config.pm file
> > -
> > package AFPA::Evolif::Config ;
> >
> > use XML::LibXML () ;
> > use XML::LibXSLT () ;
> > use XML::XPath () ;
> > use XML::Simple () ;
> > use DBI () ;
> [ ... ]
>
> Hi,
> Could it be that XML::XPath does file tests on the
> file $xmlfile passed to it through
>   XML::XPath->new(filename => $xmlfile)
> which would cause '_' to use the stat on $xmlfile, rather
> than the original config file?
>
> best regards,
> randy kobes
>
>



oh yes, this was the answer !  XML::XPATh->new stats the file.

thanks for clearing it out !

then maybe the last line of reread_conf  in mod_perl guide should be
modified to

 $MODIFIED{$file} = -M $file;

  in case the do ( ) loads something which can possibily stat file.


pascal barbedor



sub reread_conf{
>  my $file=shift;
>  return unless $file;
>  return unless -e $file and -r _;
>  unless ($MODIFIED{$file} and $MODIFIED{$file}== -M _){
>   unless (my $result = do $file){
>print "lecture\n";
>warn "lecture de $file impossible: $@" if $@;
>warn "do de $file impossible: $!" unless defined $result;
>warn "run de $file impossible" unless $result;
>   }
>   $MODIFIED{$file} = -M _
>  }
> }







Re: how to catch a killed task?

2001-10-07 Thread Perrin Harkins

> it just killed the task at soft limit without calling "cleanup". what is
> wrong?

I believe the limiting done by BSD::Resource is pretty harsh and may
actually be at the kernel level.  I don't think you can catch the signal and
deal with it yourself.  What you should do is use Apache::SizeLimit to
handle your size constraints, and just use BSD::Resource for extreme cases,
i.e. out of control servers in tight loops.

> or is there another possibility for cleaning up? probably there is a
> handler i can use which will be called when a program is finished, if
> so, how can i check if the program has ended as it shoulds or if it was
> killed by BSD::resource ?

Put your cleanup code in a PerlChildExitHandler.  Apache::SizeLimit will
allow this to be called, since it uses the $r->child_terminate() call.
BSD::Resource just does a harsh kill.

- Perrin




Re: piece of code in mod_perl guide

2001-10-07 Thread Randy Kobes

- Original Message -
From: "pascal barbedor" <[EMAIL PROTECTED]>
To: "Stas Bekman" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, October 07, 2001 12:03 PM
Subject: Re: piece of code in mod_perl guide


>
> - Original Message -
> From: "Stas Bekman" <[EMAIL PROTECTED]>
> To: "pascal barbedor" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Sunday, October 07, 2001 2:22 PM
> Subject: Re: piece of code in mod_perl guide
>
> > > I have located that if i change  $MODIFIED{$file} = -M _;   to  an
> > > explicit  $MODIFIED{$file} = -M $file;
> >
> > That's weird. _ uses the cached stat's output from the last stat call.
> > Does this work for you?
> >
> > perl -e '-s "/etc/passwd"; print -M _'
> >
>
> yes it works, but the piece of code in mod_perl guide does not work, on my
> specific config.pm, I don't understand why.
> see below, the code,  the output of the code, the config file  .
>
> In fact, it looks like when I try it on any other file that my config
file,
> it works. or it works on my config file with the explicit -M $file instead
> of -M _.
>
> for (1..10){ reread_conf("l:/config.pm") }
> our %MODIFIED;
> sub reread_conf{
>  my $file=shift;
>  return unless $file;
>  return unless -e $file and -r _;
>  if ($MODIFIED{$file} and $MODIFIED{$file}== -M _){
>  print  "same"  } else { print "different" }
>  print "\n";
>  unless ($MODIFIED{$file} and $MODIFIED{$file}== -M _){
>   unless (my $result = do $file){
>print "lecture\n";
>warn "lecture de $file impossible: $@" if $@;
>warn "do de $file impossible: $!" unless defined $result;
>warn "run de $file impossible" unless $result;
>   }
>   print "\nmod:",$MODIFIED{$file},' :', -M _,"\n";
> $MODIFIED{$file} = -M _
>  }
> }
>
[  ]
> config.pm file
> -
> package AFPA::Evolif::Config ;
>
> use XML::LibXML () ;
> use XML::LibXSLT () ;
> use XML::XPath () ;
> use XML::Simple () ;
> use DBI () ;
[ ... ]

Hi,
Could it be that XML::XPath does file tests on the
file $xmlfile passed to it through
  XML::XPath->new(filename => $xmlfile)
which would cause '_' to use the stat on $xmlfile, rather
than the original config file?

best regards,
randy kobes





Re: piece of code in mod_perl guide

2001-10-07 Thread pascal barbedor


- Original Message -
From: "Stas Bekman" <[EMAIL PROTECTED]>
To: "pascal barbedor" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, October 07, 2001 2:22 PM
Subject: Re: piece of code in mod_perl guide


> >
> >
> >
> > I have located that if i change  $MODIFIED{$file} = -M _;   to  an
> > explicit  $MODIFIED{$file} = -M $file;
>
>
> That's weird. _ uses the cached stat's output from the last stat call.
> Does this work for you?
>
> perl -e '-s "/etc/passwd"; print -M _'
>

yes it works, but the piece of code in mod_perl guide does not work, on my
specific config.pm, I don't understand why.
see below, the code,  the output of the code, the config file  .

In fact, it looks like when I try it on any other file that my config file,
it works. or it works on my config file with the explicit -M $file instead
of -M _.


If you can find any explanation...

pascal barbedor



code run
: --
--


print -s 'l:/config.pm',"\n", -M _,"\n";



for (1..10){ reread_conf("l:/config.pm") }


our %MODIFIED;


sub reread_conf{

 my $file=shift;

 return unless $file;

 return unless -e $file and -r _;

 if ($MODIFIED{$file} and $MODIFIED{$file}== -M _){

 print  "same"  } else { print "different" }

 print "\n";


 unless ($MODIFIED{$file} and $MODIFIED{$file}== -M _){


  unless (my $result = do $file){

   print "lecture\n";

   warn "lecture de $file impossible: $@" if $@;

   warn "do de $file impossible: $!" unless defined $result;

   warn "run de $file impossible" unless $result;

  }


  print "\nmod:",$MODIFIED{$file},' :', -M _,"\n";

$MODIFIED{$file} = -M _;

 }


}



---
output of code (see that the first stat worked and gives an age of very few
fraction of days, where reread_conf gives 66 days.)
with -M _ last line

983
0.00259259259259259
different

mod: :
different

mod: :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481
different

mod:67.2868981481481 :67.2868981481481

Bonne exécution du processus


-
output of code with -M $file last line

983
0.0047337962962963
different

mod: :
same
same
same
same
same
same
same
same
same

Bonne exécution du processus



--
config.pm file


package AFPA::Evolif::Config ;

use XML::LibXML () ;
use XML::LibXSLT () ;
use XML::XPath () ;
use XML::Simple () ;
use DBI () ;

my $base='l:/perlinclude';

$CHASH{pconn}->disconnect() if $CHASH{pconn};


our  %CHASH = (

indicateurs =>
XML::LibXML->new->parse_file('l:/perlinclude/indicateurs.xml')
,
glups  =>
XML::LibXSLT->new->parse_stylesheet
(XML::LibXML->new->parse_file("l:/perlinclude/glups.xsl"))
,
groupes =>XML::XPath->
  new(filename=>"l:/perlinclude/categories/groupements.xml")
,
zones =>XML::XPath->
  new(filename=>"l:/perlinclude/categories/decoupages.xml")
,
select=>XML::LibXSLT->new->parse_stylesheet
(XML::LibXML->new->parse_file("l:/perlinclude/evselecteur.xsl"))
,
pconn=>DBI->connect("DBI:mysql:database=evolif;host=localhost",
   "pconn",
   undef,
{RaiseError=>1}
   )
,


) ;


#my $stylesheet=

#  XML::LibXSLT->new->parse_stylesheet (F_GLUP_XML);


#print $stylesheet->transform(F_IND_XML);


1 ;











Apache::Request UPLOAD_HOOK

2001-10-07 Thread Issac Goldstand



The documentation on how to use this feature is a 
bit sketchy... Can anyone explain:
  1) What the variables passed to the callback 
function are (looks like the Apache::Upload object is the first, but what's been 
filled in there when the hook gets called? The second looks like the current 
bunch of data that's been recieved[?], the third is the length, but is that the 
length recieved so far or the length recieved between the last time it was 
called and this time?  And lastly, what can be placed in HOOK_DATA - scalar 
only?)
  2) Is there any way of knowing how often the 
hook will get called?
  3) Is there a specific phase of the Request 
that Apache::Request must be called and initialized with the callback 
before?
  4) Are there any specific issues for using 
this with Apache::Request->instance ?
 
Thanks,
  Issac
 
 
Internet is a wonderful mechanism for making a fool 
ofyourself in front of a very large audience.  
--Anonymous
 
Moving the mouse won't get you into 
trouble...  Clicking it might.  --Anonymous
 
PGP Key 0xE0FA561B - Fingerprint:7E18 C018 D623 
A57B 7F37 D902 8C84 7675 E0FA 561B
 
 
 
 


Re: how to catch a killed task?

2001-10-07 Thread Stas Bekman

Christoph Bergmann wrote:

> hi...
> 
> i use BSD::Resource to limit the ressources of the apache tasks. this
> works fine but now i want to clean up afterwards but i don't know how to
> catch a killed task... here is what i tried with signals:
> 
> my entries in httpd.conf:
> 
> PerlModule Apache::Resource
> PerlSetEnv PERL_RLIMIT_CPU 120:150
> PerlSetEnv PERL_RLIMIT_AS 3000:3500
> PerlChildInitHandler Apache::Resource
> 
> and this is how i tried to catch the signals:
> 
> sub cleanup { die "cleanup called..."; }
> $SIG{XFSZ} = \&cleanup;
> 
> i use linux, thus i have to use RLIMIT_AS and so maybe XFSZ is the wrong
> signal for the RAM limit. which do i have to use then?
> 
> but i tried $SIG{XCPU} but it doesnt work as well.
> 
> it just killed the task at soft limit without calling "cleanup". what is
> wrong?
> 
> or is there another possibility for cleaning up? probably there is a
> handler i can use which will be called when a program is finished, if
> so, how can i check if the program has ended as it shoulds or if it was
> killed by BSD::resource ?
> 
> thanx in advance!
> 
> best regards,
> 
> christoph bergmann
> 



Does the following help? (Look at the register_cleanup method)


http://thingy.kcilink.com/modperlguide/debug/Safe_Resource_Locking_and_Cleanu.html

-- 


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




Re: piece of code in mod_perl guide

2001-10-07 Thread Stas Bekman

pascal barbedor wrote:

> hello,
> 
>  
> 
> I am reading mod_perl guide and i had a problem with a piece of code in 
> chapter 9.7.4.2 about
> 
> reloading configuration files. this is version jan 2001 but i have 
> checked in the last one the piece of code is the same.
> 
>  
> 
> when running the code exactly, things don't work, even outside mod_perl 
> environnment.
> 
>  
> 
> the sub below print  file is different even though I don't change the file.
> 
>  
> 
> I have located that if i change  $MODIFIED{$file} = -M _;   to  an 
> explicit  $MODIFIED{$file} = -M $file;


That's weird. _ uses the cached stat's output from the last stat call. 
Does this work for you?

perl -e '-s "/etc/passwd"; print -M _'

use some existing file of course.



> in the last line, everything works fine.
> 
>  
> 
>  
> 
> since i do no test on any other file and I have understood that _ 
> account s for the last file tested, I don't understand why it does work.
> 
> I am on NT4 perl 5.6.1
> 
> try it yourself ! so strange !
> 
>  
> 
>  
> 
> thanks for any explanation
> 
>  
> 
>  
> 
> *
> 
>  
> 
> for (1..10){
> 
>  
> 
> reread_conf("l:/asperl/site/lib/afpa/evolif/config.pm");
> 
>  
> 
> sleep 2;
> 
>  
> 
> }
> 
>  
> 
>  
> 
>  
> 
> our %MODIFIED;
> 
> 
> sub reread_conf{
> 
>  
> 
>  my $file=shift;
> 
>  
> 
>  return unless $file;
> 
>  
> 
>  return unless -e $file and -r _;
> 
>  
> 
>  if ($MODIFIED{$file} and $MODIFIED{$file}== -M _){
> 
>  
> 
>  print  "same" ; }else {print "different";}
> 
>  
> 
>  print "\n";
> 
>  
> 
> 
>  unless ($MODIFIED{$file} and $MODIFIED{$file}== -M _){
> 
> 
> unless (my $result = do $file) {
> 
> warn ...
> 
>  
> 
>  }
> 
>  
> 
> 
>   print "\nmod:",$MODIFIED{$file},' :', -M _,"\n";
> 
>  
> 
> $MODIFIED{$file} = -M _;
> 
>  
> 
>  }
> 
>  
> 
> 
> }
> 
>  
> 
>  
> 



-- 


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/