Apache::Reload - patch - fixes problems with using dynamic @INC

2002-10-13 Thread Randy Harmon


I started using a dynamic INC (set up in a TransHandler), and discovered
that Apache::Reload (v0.07) was not doing its job correctly in that case.
Note, changing INC in a transhandler won't have the desired Apache::Reload
effects unless the PerlInitHandler for Apache::Reload is placed in a
Location section of httpd.conf.

The following patch corrects this, though it adds a few extra stat() calls
if the module is found at the end of INC instead of near the beginning (as
mine are).  You could make this behavior an optional one for strange folks
like me :).  Oh, I just added that to the patch manually:

   PerlSetVar ReloadDynamicInc 1

...will enable this INC-scanning behavior.  I think I hacked the patch
correctly :)

Note, if a module is loaded with one INC, then on a subsequent request,
INC changes such that the module would be not-found, the module is not
removed from memory.  If you do that and use it from a script (served when
INC doesn't have the module), you'll get erratic behavior - it'll work fine
sometimes and error out other times.  So don't do that., as a wise man
said.  Instead, make sure INC always has the right libs for your script -
test from a freshly-started server to be sure.

Separate from this strange Dynamic-@INC use case, there's another bug in the
release version of the module: if you moved a module from one INC dir to
another, the INC loop at the top of handler() would not find the file, as
it was looking for inc-dir/full-path-name instead of
inc-dir/relative-path-name.  This patch should fix this too, whether
ReloadDynamicInc is used or not.

I haven't tested this with wildcard settings or ReloadAll.

Enjoy,

Randy


--- Reload.pm   Sat Oct 12 16:22:02 2002
+++ Reload.pm.new   Sat Oct 12 17:08:07 2002
 -108,35 +108,40 

 while (my($key, $file) = each %Apache::Reload::INCS) {
 local $^W;
 warn Apache::Reload: Checking mtime of $key\n if $DEBUG;

 my $mtime = (stat $file)[9];

-unless (defined($mtime)  $mtime) {
-for (INC) {
-$mtime = (stat $_/$file)[9];
-last if defined($mtime)  $mtime;
-}
-}
+
+my $found = $file;
+if( $r-dir_config(ReloadDynamicInc) || !$mtime ) {
+# seek out the file in INC.
+my $mt;
+for (INC) {
+$mt = (stat $_/$key)[9];
+$mtime = $mt, $found = $_/$key, last if defined($mt) 
$mt;
+}
+}
+
 warn(Apache::Reload: Can't locate $file\n),next
 unless defined $mtime and $mtime;

 unless (defined $Stat{$file}) {
 $Stat{$file} = $^T;
 }

-if ($mtime  $Stat{$file}) {
+if( $found ne $file || $mtime  $Stat{$file} ) {
 delete $INC{$key};
 if (my $symref = $UndefFields{$key}) {
 #warn undeffing fields\n;
 no strict 'refs';
 undef %{$symref};




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: New mod_perl site and oddness with IE

2002-07-16 Thread Randy Harmon

IE 5.5 on win2k as well.

 -Original Message-
 From: Issac Goldstand [mailto:[EMAIL PROTECTED]]

 Not just you.  I have the same problem under MSIE.

  Has anyone else had problems with this particular page under IE
  (6.0.2600 under XP) being extremly slow to update when paging up/down?

http://perl.apache.org/docs/1.0/guide/performance.html#Improving_Perform





RE: TransHandler called a second time after I've returned DECLINED

2002-07-09 Thread Randy Harmon

Rick, I hope you don't mind I've followed this up to the list.  Your reply
was *very* useful to me, and I hope others may benefit from it...since I
didn't find any archived information that was helpful and all.

 -Original Message-
 From: Rick Myers [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 03, 2002 7:00 PM

 Sorry for the late reply, but I don't read the list daily.
 (Erm, or even weekly it seems. :-)
 On Jun 25, 2002 at 08:26:37 -0700, Randy Harmon wrote:

Heh, the weeks do tend to fly by.  There goes another one now.

  I'm using a TransHandler, and having a problem where it sometimes gets
  called twice when I don't expect it
[...]
  On an example request for /exists/non-existent-dir/file.html,

[on the second, unexpected, TransHandler call]

  the uri() is screwed up as /file.html.  If the request is
  /exists/non/foo/file.html, then uri() is /foo/file.html on
  the second (unexpected) call to my TransHandler.

[Rick:]
 That's an example of Apache's simplistic approach to
 matching URL's to physical disk space. I don't recall if it
 was mod_perl or Apache that actually called the TransHandler
 twice, but I suspect the latter. Here's how I worked around
 it...

 PerlPostReadRequestHandler AlterTrans

 package AlterTrans

 sub handler {
 my ($r) = @_;
 return DECLINED if $blah_blah_blah;
 for (@{$r-get_handlers('PerlTransHandler')}) {
 /::handler$/ or $_ .= '::handler';
 my $rv = {\$_}($r);
 $rv != DECLINED and return $rv;
 }
 $r-set_handlers('PerlTransHandler', undef);
 OK;
 }

 Basically, what it does is calls your TransHandlers one at a
 time from the PostReadRequest phase.

 --rick

 Hmm.. maybe this is of interest?

 NAME
Apache::AlterTransChain - Alters the chaining behaviour of
[cut: rest of perldoc]

That is interesting.  I remain with trouble, in that my TransHandler relies
on things that apparently aren't available at the PostReadRequest phase -
specifically dir_config settings don't seem to be available when I use this
approach.

I was successful in using $r-set_handlers('PerlTransHandler', undef) in my
TransHandler, which apparently avoids the implicit subrequest that occurs
after I decline my TransHandler for a non-existent file like described
above.

There's still an interesting issue, where a subrequest that I *intend* to do
(while serving a site-branded error message) still has the original
filename - so I had to call $r-filename('/path/to/error_message.html')
before my subrequest would do the right thing.  But that problem is
independent of my above fix.

Thanks for the information, Rick.  Very helpful!

Randy




TransHandler called a second time after I've returned DECLINED

2002-06-25 Thread Randy Harmon


I'm using a TransHandler, and having a problem where it sometimes gets
called twice when I don't expect it - in most cases it's called just once as
I expect.

When I specify a file in a directory that doesn't exist (I'm going to use
path_info in a Mason dhandler, either to deliver a custom 404 with
autohandler, or for various other nefarious purposes), my TransHandler is
being called twice.  The first time, it gets the correct $r-uri(), and I
determine that I don't want to translate the request - returning DECLINED.
The second time, the uri() is jimmied.

On an example request for /exists/non-existent-dir/file.html, the uri() is
screwed up as /file.html.  If the request is /exists/non/foo/file.html, then
uri() is /foo/file.html on the second (unexpected) call to my TransHandler.

I've trimmed my server's vhost configuration down to this bare minimum:

VirtualHost IP:PORT
ServerAdmin [EMAIL PROTECTED]
ServerName  randy.www.customer.com
DocumentRoot/www/home/cust/dev/randy/www.customer.com/

PerlTransHandler My::Trans

Location /
SetHandler perl-script
PerlHandler My::MasonHandler

order allow,deny
allow from all
/Location
/VirtualHost

Note, if I remove the PerlHandler, the TransHandler isn't getting called at
all, even though I've specified it.  The two packages are defined in a
single init script that's still doing fine for other vhosts.

I've troubleshot quite a bit, and the call-stack when I'm called twice is
exactly the same (/dev/null is the caller).  The pid and perl interpreter is
the same for both, so I can work around it with a package-global variable
and $r-uri( $foo ) and a $r-register_cleanup( sub{$foo=0}).  But not with
$r-pnotes() - it doesn't hold the value!

I don't see anything My::MasonHandler is doing (push_handlers, for instance)
that should cause a second transhandler to be called for - besides which,
that code isn't run until later anyway.

perl 5.005_03
Apache.pm v1.27
compiled into apache, not DSO

I know this Perl version isn't up to the moment, but I've had various
problems with the more up-to-date perls, and none with this version - unless
this turns out to be the exception :)

Has anybody experience with such a problem?  Anybody using this perl and
mod_perl with a transhandler of such a nature, with success?  Anyone have
suggestions I should try?

Thanks,

Randy




RE: Re[2]: mod_perl memory leaks on Windows

2002-06-25 Thread Randy Harmon

Apache 1.3.x has always been experimental and not-for-production-use on
Win32 :(

Hopefully these modules will support Apache 2.0 pretty soon, for your sake.

Randy

 -Original Message-
 From: Andrey Prokopenko [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 25, 2002 8:31 AM
 To: [EMAIL PROTECTED]
 Subject: Re[2]: mod_perl memory leaks on Windows


 Hello Perrin,
 Tuesday, June 25, 2002, 6:40:01 PM, you wrote:
 PH Andrey Prokopenko wrote:
  After a fresh restart, I started Apache/mod_perl. Then i issued a
  little stress test using simple perl script with LWP::Simple.
  I ran a performance test on /mod_perl/index.pl page for 10 minutes. The
  source code of that page is given below :
  -
  #!/perl/bin/perl
  use CGI qw(:all);
 
  print header;
  print Hello, World!;
  -
  After 10 mintues of execution, the memory consumption of Apahce.exe
  had jumped from approx 5 MB to 120MB ( virtual memory ).
  I ve noticed, that Apache child grown by 4-8kb per each request.

 PH Have you tried it without using CGI.pm?  Have you tried writing a
 PH handler instead of using Apache::Registry?
 yep, i wtite a totally simple cgi
 --
 #!/perl/bin/perl
 use strict;
 print Content-type: text/plain\n\n;
 print Hello, World!;

 --

 and the same simpliest handler:
 --
 package MyTest;
   use Apache;
   use Apache::Constants;
   sub handler{
 my $r = shift;
 print $r-send_http_header(text/html);
 print h1HELLO WORLD!/h1;
 return OK;
   }
 1;
 --

 and still no luck ;(((
 Apache child still continued to grow in both cases. ;(((
 I even turned off KeepAlive option in httpd.conf
  I know that mod_perl on Windows is a development version but still
  this memory leak thing is pretty obvious and should have been taken
  care off.
 PH There's a pretty good chance that it's not mod_perl causing
 it.  It may
 PH be just that Win32 perl grows a little when you run that CGI::header
 PH call over and over.
 I tried a plain Perl cgi script, with no module used, and still the
 same. ;((
 Do you mean that this leak cannot be fixed from Apache/mod_perl side ?
 PH The upcoming mod_perl 2 will have better support for Windows.
  You can
 PH find information on it here:  http://perl.apache.org/release/docs/
 Sorry, but for now we're stuck with Apache 1.3.x, because we use
 module, which
 cannot work with Apache 2.0. So i seek appropriate solution based on
 Apache 1.3 version.

 --
 Best regards,
  Andreymailto:[EMAIL PROTECTED]







Re: how do I store/retrieve a hash through Apache::Session?

2000-11-03 Thread Randy Harmon


Once you realize that %session entries have to be scalars (references) as
described by other responses, be sure when you change entries in the
sub-hash that you tell the top-level session that the data's been changed
(it won't realize it unless you change one of its scalars).

Check the docs or the archives for the "official way" to do this (a message
from Jeffrey Baker uses such a phrase), but any modification of a %session
scalar will do - $session{_changed}++; , f'rinstance.

Best,

Randy

On Fri, Nov 03, 2000 at 04:36:15PM +, Enrique I . Rodriguez wrote:
 Maybe a silly question... 
 
 how do I store/retrieve a hash through Apache::Session?
 
 This doesn't work...
 # retrieve
 %table=$session{table};
 ...
 # store
 $session{table}=%table;
 
 What's my fault?



Re: VirtualSellers.com TAME patent

2000-01-10 Thread Randy Harmon


IANAL, but I understand that technologies that were in the public domain can
not be patented.  And if a patent is issued, it's not enforcable in that
case.  Again, IANAL, but I feel that FreeType falls in that same category
(see http://www.freetype.org).

Randy


On Mon, Jan 10, 2000 at 11:43:47AM -0800, Cliff Rayman wrote:
 looks like they submitted a patent for an embedded mark-up language.
 the language can actually be embedded inside an html page (what
 a concept!).
 
 see virtualsellers.com  and the TAME language section.
 patent filing info was on business wire.
 
 soapbox
 These patents scare me since the patent granters seem not to understand
 software very well - and it seems like it is diametrically opposed
 to what the open software movement stands for.
 /soapbox
 
 cliff rayman
 genwax.com
 



Re: mysql.pm on Apache/mod_perl/perl win98

2000-01-10 Thread Randy Harmon

[cc list trimmed; this is more a mod_perl issue than a mysql one.]

Thanks a bunch for your efforts here.  I understand that earlier such
bundles were built with VC6, eh?  Will you have the
opportunity/ability/tuits to distribute one built with Cygwin, so that the
resultant installation can freely install new/updated modules from CPAN,
including those that need a C compiler?  I wouldn't suggest to bundle
Cygwin, but to work with its standard install location, at any rate.

The reason I ask is that I'd like to have a distribution available that
includes HTML::Mason, and which is open for folks to add the precise modules
that they need.  Combined with SSH and CVS, this becomes a pretty decent
development environment even for a web developer with only a Windows box.

Perhaps it's more reasonable to request that you add HTML::Mason into the
existing bundle, but that will have its own share of difficulties,
considering the other unspecified modules that people would still be
without.  A cygwin-based distribution perhaps could simply ship with Perl's
base install - let the user install their packages through CPAN.

I've looked at getting apache/perl/mod_perl to build wtih cygwin, but I
lacked the knowledge to understand the build hints for Perl, speak nothing
of the rest.

By the way, HTML::Mason may still have a problem here or there on Windows,
which we folks on the Mason list will be glad to help get ironed out, I
believe.  At least, I'd be willing to help.

Randy



On Mon, Jan 10, 2000 at 04:10:08PM -0600, Randy Kobes wrote:
 On Mon, 10 Jan 2000, Tim Tompkins wrote:
 
  There is a DBD::mysql available from ActiveState.  You can install it with
  ppm.
  
  ppm install DBD-mysql
 
 Hi,
This would normally work, but the perl binary being used
 most probably isn't ActiveState's, because as of yet
 mod_perl doesn't work with ActiveState's perl. So there
 would most likely be a binary incompatibitly using
 this perl binary with ActiveState's DBD::mysql.
 I'm currently testing out an apache/mod_perl/perl
 Win32 binary that will have DBD::mysql and DBD::msql
 support, as well as mod_ssl. As a new mod_perl
 version is in the works, I'll probably wait until
 that is released.
 
 best regards,
 Randy Kobes
  
 



Re: Caching with $r-no_cache(1)

2000-01-09 Thread Randy Harmon

On Sun, Jan 09, 2000 at 08:45:11PM +, G.W. Haywood wrote:
 On Fri, 7 Jan 2000, Randy Harmon wrote:
 
  Does anybody have experience detecting such a condition, perhaps through one
  of the client headers?  I haven't had a chance to dump them - many hats.
 
 No idea - ditto.
 
  In any case, I could use some Javascript to package up the machine's
  current time and send it back to the server, for instance at the
  same point where I check whether a cookie was accepted.  That'd
  indicate their "Javscript-OK"-ness too.  I think I'm willing to
  assume that someone clueful enough to turn off Javascript is clueful
  enough to have the correct time.
 
 You might want to look at the excellent ntpd documentation which talks
 about things like network delays.  I think your Javascript idea is as

Fortunately, network lag only works in our favor when it comes to this
technique.  So it expires a few hundred milliseconds in the past instead of
"now"... no biggie to me.

 good a solution as you're going to get until the Web Comes Of Age.
 Don't know what you're going to do when I visit with Lynx though...

I'm going to hope that Lynx is smarter than Netscape on this point, and
assume that you're clueful enough to have the correct time. 

 Well, at least my clock _will_ be right, I run a level 3 timeserver.

He... I'm with you.  Oh, good, my assumption was right. :)

Randy



Caching with $r-no_cache(1)

2000-01-07 Thread Randy Harmon


I notice that the Guide omits the mention of Netscape's ignorance of
Expires: set to the same as Date: when it mentions $r-no_cache(1)
performing that function.  

Currently, I'm experiencing the problem with Netscape 4.7, although I seem
to recall the same problem in earlier releases, in the case where the target
browser's clock is slow.

Of course, the server-side workaround (since we can't just fix our visitor's
clocks) is to set an Expires header that significantly in the past, for some
definition of 'significant'.

I'm going to assume that $r-no_cache(1) won't be kludged to fix Netscape's
bug, although some would argue that it should be 'fixed' in mod_perl.

As an update to /guide/correct_headers.html#2_1_3_Expires_and_Cache_Control,
I'd suggest adding the following text at the end:

[ ... works with the major browsers. ] However, Netscape clients with slow
clocks may not honor the 'immediate' timeout, cacheing pages anyway. 
This can be corrected by explicitly setting an Expires header that's in
the past.  How far in the past depends on how lenient you wish to be with
browsers with slow clocks.

Something between 5 and 30 minutes seems reasonable to me, but discussion
may demonstrate a different approach and/or timeframe.

Thoughts?

Randy



Additions to the Apache::Session docs

2000-01-06 Thread Randy Harmon

Unless someone wants to implement multi-level tied hashes (/arrays) to
correct the following problem, something like the following should
make it into the Apache::Session documentation.  I hope it helps some
folks.

Randy

---

When you store a hashref in a tied Apache::Session hash, subsequent
accesses to that underlying sub-hash do not go through the
Apache::Session tied-hash interface, and Apache::Session will not
recognize that changes have been made  (I suspect that similar direct
access to a listref will behave the same way).

The changes to Apache::Session to enable recognition of such accesses
are non-trivial, particularly when multi-level hashes are desired.

In order to force Apache::Session to recognize such a change, you may
wish to access a scalar entry, such as by:

$session{'fix_hashref_storage'}++;





Re: ApacheDBI vs DBI for TicketMaster

2000-01-02 Thread Randy Harmon

On Sun, Jan 02, 2000 at 01:48:58AM -0600, Ed Loehr wrote:
 My apache children are seg faulting due to some combination of
 DBI usage and the cookie-based authentication/authorization
[...]
 child seg faults.  If I comment out all DBI references in the

Hm, are you connecting to your database prior to Apache's forking - i.e., in
your startup.pl?  That could cause trouble, especially on older versions of
Apache and Apache::DBI.

 Any clues?

Not much of one.  Hope it helps.

Randy



Re: mod_perl Programmers demand is going up...

1999-12-03 Thread Randy Harmon

On Fri, Dec 03, 1999 at 11:38:35PM -0700, Michael Dearman wrote:
 
 
 "G.W. Haywood" wrote:
  How about ``Eagle''?

 Exactly what I was just thinking.
 Apache Stronghold
 Apache Eagle

Um, isn't that animal taken by O'Rielly?

How about an oyster?  Perhaps not as american-patriotic but just think how
sexy it sounds.

Randy

 Logo?
 Eagle floating over the feather? Or, the feather floating under the
 Eagle.
 An Eagle Feather.  



Re: Redhat httpsd with mod_perl

1999-10-21 Thread Randy Harmon

On Wed, Oct 20, 1999 at 10:47:02PM -0700, Adi wrote:
  On Wed, 20 Oct 1999, Remi Fasol wrote:
 Does anyone know why the shared memory would decrease so dramatically? 

Perl code and data both live in the data segment.  As it is used, any time
it writes information into a new chunk of memory, the memory is
copied-on-write, becoming not-shared.  

You may or may not benefit from exiting your Apache child when its shared
memory size shrinks too much.  I think a package of Stas Bekman's
authorship may help you detect that occasion.  It wraps the gtop library in
perl, so you can monitor 'top' info from mod_perl.

Your own tests will give you an indication of whether this saves memory and
should also indicate whether there is any performance advantage one way or
other.

It'd be interesting to hear your story of the results.

Randy



Re: Another IE5 complaint

1999-10-02 Thread Randy Harmon

On Sat, Oct 02, 1999 at 03:21:17PM -0400, Greg Stark wrote:
 "Joe Pearson" [EMAIL PROTECTED] writes:
[]
  whenever a IE5 user visits a page in their "Favorites", IE5 also trys
  to GET favicon.ico from the same site.  Therefor I have hundreds of
  "File does not exist:"  errors in my log file.
[...]
 Can the gimp save .ico files? How big and what colours etc does IE5 expect

Unknown.

 these to be anyways?

http://www.wdvl.com/Authoring/Design/Images/Favicon/index.html

Randy