Verifying Which Handler

2002-08-08 Thread Jeff Crist
Title: Message



Can someone send me 
an example of a test Perl script that will display which Perl handler Apache is 
using - Apache::Registry or PerlRun.

We just migrated our 
website to a new server that was initially setup to run Appache::Registry but we 
don't have time to cleanup the code so I change the configuration (at least 
thought I did) to PerlRun. However we are seeing random behavior 
whenrunning scripts on ourwebsite (the content of the page 
unexplainably changes sometimes) that seem to indicate variables are not being 
reset (ie, maybe we are still using the Apache::Registry handler) 
Another tipoff was when he had to go change all the exit commands in the Perl 
scripts to Apache::exit();



Re: Getting ugly: mod_perl and traditional forms of writing CGI

2002-08-08 Thread Andrew Ho

Hello,

SSThe below is a sample bit of code I am using for very simple forum
SSsoftware. It acts erratically, sometimes seeing the contents of the form
SSbeing POSTed to it and sometimes not. If a form POSTed is under 500
SSbytes in length it works fine. Anything higher is hit and miss.
SS
SScommunity.cgi:
SS--
SSpackage Kittens::Community;

You don't want to use an explicit package statement in an Apache::Registry
script because Apache::Registry creates its own package name for the
current script. I can't find a on-line reference for this right now, but I
recall it causing sporadic problems.

SSI'm thinking that the step of going from writing simple Perl CGI scripts
SSto mod_perl is one that many people will be going through and a
SSdocumenting a lot of this (basic mod_perl writing techniques) online
SSwould be incredibly helpful. So you're not just helping me, you're
SShelping an entire future community of mod_perl developers.

You should really take some time to look through the excellent mod_perl
Guide, which is exactly this, a bunch of knowledge compiled together in a
tutorial type way. You can read the Guide on-line here:

http://perl.apache.org/docs/1.0/guide/

In fact, there is a section specifically discussing converting CGI scripts
to run under mod_perl.


http://perl.apache.org/docs/1.0/guide/getwet.html#Porting_Existing_CGI_Scripts_to_run_under_mod_perl

In general, you will get much better error reporting and if you are
running with warnings and use strict in all of your scripts. You can
find out how to enable these in the Guide.

Humbly,

Andrew

--
Andrew Ho   http://www.tellme.com/   [EMAIL PROTECTED]
Engineer   [EMAIL PROTECTED]  Voice 650-930-9062
Tellme Networks, Inc.   1-800-555-TELLFax 650-930-9101
--





Re: solaris 2.6, mod_perl 1.27, apache 1.3.26, resulting serverfails

2002-08-08 Thread John E. Mendenhall

Lupe,

On Thu, 8 Aug 2002, Lupe Christoph wrote:

 On Thursday, 2002-08-08 at 10:16:44 -0700, John E. Mendenhall wrote:
  On Thu, 8 Aug 2002, Lupe Christoph wrote:

   Syntax error on line 1341 of /usr/local/apache/conf/httpd.conf:

   Can't locate loadable object for module Apache::Log in @INC (@INC
   contains: /opt/cybercash/mck/perl-api
   /usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1
   /usr/local/lib/perl5/site_perl/5.6.1/ sun4-solaris
   /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl
   /usr/local/lib/perl5/si te_perl/sun4-solaris .
   /usr/local/apache-mod_perl/ /usr/local/apache-mod_perl/lib/perl) at
   /usr/local/li b/perl5/site_perl/5.6.1/sun4-solaris/mod_perl.pm line 14

 This looks OK.

 Since mod_perl seems to play tricks with bootstrap, I don't really
 know how this comes into play. The fate of Log.xs from
 mod_perl-1.26/src/modules/perl/Log.xs is:
 it is copied to apache_1.3.22/src/modules/perl/Log.xs, and
 apache_1.3.22/src/modules/perl/Log.c is generated from it.
 That in turn produces Log.o, which in the statically linked case
 I have, goes into libperl.a. And that is linked into httpd.

 Please check your apache_1.3.27/src/modules/perl for Log.*.
 If you have the three files, do ar tv libperl.a and look for Log.o.
 If this is still present, do nm httpd | grep XS_Apache__Log.
 You should get a couple of lines like this:
 [3561]  |503856| 232|FUNC |GLOB |0|9  |XS_Apache__Log_alert
 [6456]  |504088| 232|FUNC |GLOB |0|9  |XS_Apache__Log_crit
 [5099]  |505248| 232|FUNC |GLOB |0|9  |XS_Apache__Log_debug
 [6188]  |503624| 232|FUNC |GLOB |0|9  |XS_Apache__Log_emerg
 [3426]  |504320| 232|FUNC |GLOB |0|9  |XS_Apache__Log_error
 [3250]  |505016| 232|FUNC |GLOB |0|9  |XS_Apache__Log_info
 [6242]  |503272| 352|FUNC |GLOB |0|9  |XS_Apache__Log_log
 [4790]  |504784| 232|FUNC |GLOB |0|9  |XS_Apache__Log_notice
 [5051]  |504552| 232|FUNC |GLOB |0|9  |XS_Apache__Log_warn

 Lupe Christoph

I have done all you have asked.  All output appears similar.  Three files,
including Log.xs.  Nine entries in httpd for XS_Apache__Log, as follows:

[2638]  |286064| 216|FUNC |GLOB |0|8  |XS_Apache__Log_alert
[3893]  |286280| 216|FUNC |GLOB |0|8  |XS_Apache__Log_crit
[3960]  |287360| 216|FUNC |GLOB |0|8  |XS_Apache__Log_debug
[3382]  |285848| 216|FUNC |GLOB |0|8  |XS_Apache__Log_emerg
[3619]  |286496| 216|FUNC |GLOB |0|8  |XS_Apache__Log_error
[2981]  |287144| 216|FUNC |GLOB |0|8  |XS_Apache__Log_info
[2566]  |285508| 340|FUNC |GLOB |0|8  |XS_Apache__Log_log
[3223]  |286928| 216|FUNC |GLOB |0|8  |XS_Apache__Log_notice
[2866]  |286712| 216|FUNC |GLOB |0|8  |XS_Apache__Log_warn

So, where to from here?  Any ideas?

JohnM

## John Mendenhall
## [EMAIL PROTECTED]
## Senior Network/Systems Administrator





PerlChildInitHandler doesn't work inside VirtualHost?

2002-08-08 Thread Jason W May


Running mod_perl 1.26 on Apache 1.3.24.

I've found that if I place my PerlChildInitHandler inside a VirtualHost
block, it is never called.

This works:

...

PerlModule  Foo
PerlChildInitHandlerFoo::handler

VirtualHost *:80

...
PerlHandler MyModule
...

/VirtualHost



but this doesn't:


VirtualHost *:80

PerlModule  Foo
PerlChildInitHandlerFoo::handler
...
PerlHandler MyModule

/VirtualHost


I don't see why VirtualHost would make a difference for child-init 
handlers.  What else could I be doing wrong?

Thanks,
-Jason





How to detect data avaliability on ARP::Socket

2002-08-08 Thread Hideki Noma

I am currently developping a private module utilizing
PerlProcessConnection handler and facing a bit of problem.
(Apache::2.0.39 + mod_perl 1.99.04)

This is the part of program:
sub handler {
 my Apache::Connection $c = shift;
 my APR::Socket $socket = $c-client_socket;

 my($rlen, $wlen);
 my $rlen = BUFF_LEN;
 $socket-recv($buff, $rlen);

At this point, if there is no incoming data from client,
the program halts forever.

What I want to do is something like
  my $sel = IO::Select-new($socket);
  if ($sel-can_read(1)){
my $socket-recv($buff, $rlen);
  }
so that I can do other works while waiting for data.

I tried to set timeout using $socket-setsocketopt(APR_SO_TIMEOUT,1)
but it didn't seem to work well.

Does any body have any idea on how to check incoming data avaliabily
on APR::Socket?

Hideki Noma
Humeia Limited Parnership



Apache::DProf not working

2002-08-08 Thread Randy Harmon


I'm having trouble making Apache::DProf work.

I've installed the module with CPAN, and I've added PerlModule Apache::DProf
at the top of my httpd.conf.  I've verified with 'httpd -l' that
PerlChildInitHandler is OK - therefore, pushing a child-init handler should
be OK, right?

I've started the server, ran the web page I want to profile (that uses
HTML::Mason), and then stopped the server.

ServerRoot/dprof is not created, nor when I create it does it create
dprof/$$ files as documented (likewise ServerRoot/logs/dprof/, as described
elsewhere in the perldoc - not self-consistent).  Also searched the entire
system for tmon.out files (not found).

Any suggestions?

Randy




RE: [Mason-devel] Re: ANNOUNCE: Mason 1.12

2002-08-08 Thread Ian Robertson

If you ax version numbers now, what happens if someone who already has
a versioned copy of ApacheHandler installed asks CPAN to upgrade it?
Will it conclude that it already has the most up to date version?  For
that matter, if another CPAN module simply lists H::M::AH as a
dependency (as opposed to H::M), which version of Html-Mason will CPAN
grab?  My guess would be the one with the highest (defined) version of
Apache::Handler.

- Ian


 JS == Jonathan Swartz [EMAIL PROTECTED] writes:

  I think we should just get rid of the version number in
  ApacheHandler.  I hate it when there's more than one version
  number per distribution.
  
  -Ken

 JS I'd be up for that too. Why *do* we have version numbers in all the
 JS individual modules?


 JS ---
 JS This sf.net email is sponsored by:ThinkGeek
 JS Welcome to geek heaven.
 JS http://thinkgeek.com/sf
 JS ___
 JS Mason-devel mailing list
 JS [EMAIL PROTECTED]
 JS https://lists.sourceforge.net/lists/listinfo/mason-devel



Can I change the browser's address/location?

2002-08-08 Thread Harry Zhu

Suppose I have a generic content handler to handle requst
/step/1, /step/2, ..., /step/n

Location /step
  SetHandler perl-script
  PerlHandler MyHandler

/Location

#MyHandler.pm
package MyHandler;
sub handler {
  my $r=shift;
  my $step = substr($r-path_info(),1);

  #do something before fetch the content

  #fetch content: usually include a form that will assign action
/step/($step+1)

}

So if everything goes well, the user will follow through from step 1, step
2, until fnish.
Now if in the #do something ... part, something is wrong, it will usually
require user go back to the same step, for example, to fill the form again.
The way my old cgi script does is just generate the form with prefilled
value plus some error message indicate what's wrong. It works ok but the
browser location will show /step/($step+1) while it actually is /step/$step.
Now that I am working it on mod-perl I thought I should be able to do
something about it. I briefly browsed the 2 mod-perl books (eagle,
cookbook), and could not found a simple solution yet  (or I missed it?). I
was think using one of the folowing might work:z
1) save the request data in a temp file and redirect or http-refresh to
/step/$step?$session_id or /step/$step/error?$session_id
Remember the content is dynamic and depend on the input form data, so simple
redirect may not work.
Looks like Apache will not post the form data when redirect with Location?

2) print a short form with hidden data and assign action=/step/$step/error
then submit right away (onload=form.submit()?)

Does anybody have a simple solution, e.g. without redirect? Is it possible
to change the URI showing in the browser's address/location bar?

I would appreciated if somebody can pointer me to the right direction.

Harry






Re: Verifying Which Handler

2002-08-08 Thread Stas Bekman

Jeff Crist wrote:
 Can someone send me an example of a test Perl script that will display 
 which Perl handler Apache is using - Apache::Registry or PerlRun.
  
 We just migrated our website to a new server that was initially setup to 
 run Appache::Registry but we don't have time to cleanup the code so I 
 change the configuration (at least thought I did) to PerlRun.  However 
 we are seeing random behavior when running scripts on our website (the 
 content of the page unexplainably changes sometimes) that seem to 
 indicate variables are not being reset (ie, maybe we are still using the 
 Apache::Registry handler)   

 From the scripts you can use Carp::cluck() or for the fine tuning caller().

You can also do it globally, set in the startup file:

$Apache::Registry::Debug = 1;
$Apache::PerlRun::Debug = 1;

and then the handlers will spit some debug info which should help.

 Another tipoff was when he had to go change 
 all the exit commands in the Perl scripts to Apache::exit();

You don't need to do that for registry scripts. It's being done for you 
behind the scenes.

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com





Re: Apache::DProf not working

2002-08-08 Thread Stas Bekman

Randy Harmon wrote:
 I'm having trouble making Apache::DProf work.
 
 I've installed the module with CPAN, and I've added PerlModule Apache::DProf
 at the top of my httpd.conf.  I've verified with 'httpd -l' that
 PerlChildInitHandler is OK - therefore, pushing a child-init handler should
 be OK, right?
 
 I've started the server, ran the web page I want to profile (that uses
 HTML::Mason), and then stopped the server.
 
 ServerRoot/dprof is not created, nor when I create it does it create
 dprof/$$ files as documented (likewise ServerRoot/logs/dprof/, as described
 elsewhere in the perldoc - not self-consistent).  Also searched the entire
 system for tmon.out files (not found).
 
 Any suggestions?

Permission problems?



__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com




Re: PerlChildInitHandler doesn't work inside VirtualHost?

2002-08-08 Thread Cees Hek

Quoting Jason W May [EMAIL PROTECTED]:

 
 Running mod_perl 1.26 on Apache 1.3.24.
 
 I've found that if I place my PerlChildInitHandler inside a VirtualHost
 block, it is never called.

It doesn't really make sense to put a PerlChildInitHandler inside a VirtualHost
directive.  It is only called when the Apache Child process is created, not when
a new request comes in.

If you explain what you are trying to accomplish, maybe we can recommend a
better Handler to tie into.

Cees



Re: mod perl load average too high

2002-08-08 Thread Ed Grimm

That looks like there's something that occasionally goes off and starts
spinning, given the low memory usage and the fact that some processes
using little cpu are also not swapped out.

I suspect that one of your pages has a potential infinite loop that's
being triggered.  Try and catch at what point the load suddenly starts
rising, and check what pages were accessed around that time.  They're
where you should start looking.

Note that you should probably focus on the access and error log lines
that correspond with processes that are using excessive amounts of cpu.

Ed

On Tue, 6 Aug 2002, Anthony E. wrote:

 I'm using apache 1.3.26 and mod_perl 1.27
 
 My apache processes seem to be taking up more and more
 system resources as time goes on.
 
 Can someone help me determine why my server load is
 going up?
 
 When i first start apache, my load average is about
 .02, but after a couple of hours, it goes up to 4 or
 5, and after a couple of days, has been as high as
 155.
 
 I have the following directives configured in
 httpd.conf:
 
 MaxKeepAliveRequests 100
 MinSpareServers 5 
 MaxSpareServers 20
 StartServers 10
 MaxClients 200
 MaxRequestsPerChild 5000
 
 Here is a snip of 'top' command:
   6:28pm  up 46 days, 23:03,  2 users,  load average:
 2.24, 2.20, 1.98
 80 processes: 74 sleeping, 6 running, 0 zombie, 0
 stopped
 CPU0 states: 99.3% user,  0.2% system,  0.0% nice, 
 0.0% idle
 CPU1 states: 100.0% user,  0.0% system,  0.0% nice, 
 0.0% idle
 Mem:  1029896K av,  711884K used,  318012K free,  
 0K shrd,   76464K buff
 Swap: 2048244K av,  152444K used, 1895800K free   
   335796K cached
 
   PID USER PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM
   TIME COMMAND
 25893 nobody16   0 10188 9.9M  3104 R95.5  0.9
  21:55 httpd
 25899 nobody16   0  9448 9448  3104 R95.3  0.9
  63:27 httpd
 25883 nobody 9   0 10468  10M  3096 S 2.5  1.0
   0:16 httpd
 25895 nobody 9   0 10116 9.9M  3104 S 2.1  0.9
   0:15 httpd
 25894 nobody 9   0 10240  10M  3104 S 1.9  0.9
   0:16 httpd
 25898 nobody 9   0 10180 9.9M  3100 S 1.7  0.9
   0:13 httpd
 
 Also, I notice in my error_log i get this entry quite
 frequently:
 26210 Apache::DBI new connect to
 'news:1.2.3.4.5userpassAutoCommit=1PrintError=1'
 
 What can i do to keep the server load low?
 
 
 =
 Anthony Ettinger
 [EMAIL PROTECTED]
 http://apwebdesign.com
 home: 415.504.8048
 mobile: 415.385.0146
 
 __
 Do You Yahoo!?
 Yahoo! Health - Feel better, live better
 http://health.yahoo.com
 




Handler Concept / Question

2002-08-08 Thread David Cumming




The basic concept I want 
to accomplish isto allow for static and dynamic content to be accessed 
from any url and be transparent to the 
visitor.

i.e
publish a static page 
called /foo/bar.htm
have a dynamic page 
called /foo/foobar.htm

I imagine there are a 
couple of different ways to do this, such as:

* Set the dynamic page 
script as the 404 handler, then all it does is determine if the content can be 
displayed from a database.

OR

* Set ALL requests to 
filter through my handler, do lookup_uri / lookup_file on it and either return 
the static content (somehow) or return a dynamic 
page.


Does anyone have any 
points of view on whether the script should just be a 404 handler or whether I 
should set a handler to listen to all requests and have my script determine what 
to do, or another way to do it?

If I do set my script to 
answer all requests, how do I tell the webserver to show the static content that 
exists under the requested url?

All comments 
welcome.

Dave

David Cumming
Webmaster
Corporate Affairs
Environmental Protection Agency
+61 7 3247 3274

www.env.qld.gov.au