[mp1] Method handler that eventually seems to "forget" it"s amethod handler

[mp1] Method handler that eventually seems to "forget" it"s amethod handler

am 02.02.2005 15:54:48 von Andrew Green

Hi,

I seem to have a bizarre problem with method handlers on my setup. I
have a set of different handlers, all of which are method handlers so
that I can easily inherit shared code across a collection of different
installations of my application on the same server.

The first handler to get invoked is a PerlTransHandler -- everything
works fine (or at least seems to) for quite some time, but then the
handler begins "forgetting" that it's a method handler, and instead of
the class being passed before $r, $r becomes the first thing passed.
At least, that seems to be what's happening. Is this a known problem?

My setup is as follows:

Perl 5.8.0 (Red Hat EL 3 default)
Apache/1.3.29
mod_perl/1.29


Here's what I imagine to be the relevant bits of httpd.conf:

MinSpareServers 10
MaxSpareServers 20
StartServers 10
MaxClients 60
MaxRequestsPerChild 1000
...

PerlTransHandler MyApp::MyInstall::Dispatcher
...


Here's the relevant bits of Dispatcher.pm:

package MyApp::MyInstall::Dispatcher;

use strict;
use Apache::Constants qw(OK DECLINED NOT_FOUND REDIRECT FORBIDDEN);
use Apache::URI;

our @ISA = qw(MyApp::Core::Dispatcher);

1;

####

sub handler ($$) {

my ($class,$r) = @_;
return DECLINED unless ($r->is_initial_req());
...


And here's the error (that only starts appearing after the server's
been running for a while:

Can't call method "is_initial_req" on an undefined value...

The error then points to the line quoted above. Of course, Apache
never gets to other handlers later in the sequence, so I can't easily
see whether the problem is limited to TransHandlers, or whether all my
method handlers would stop acting as such. Restarting the server makes
the problem go away -- for a while!

I'd really like to avoid having to upgrade/change Perl or mod_perl if
at all possible. Nonetheless, any help, advice or guidance anyone can
provide would be very much appreciated.

Cheers,
Andrew.

Re: [mp1] Method handler that eventually seems to "forget" it"s amethod handler

am 02.02.2005 16:10:56 von Geoffrey Young

>
> PerlTransHandler MyApp::MyInstall::Dispatcher

make that

PerlTransHandler MyApp::MyInstall::Dispatcher->handler

and see if that helps. you should also be preloading via

PerlModule MyApp::MyInstall::Dispatcher

or in a startup.pl.

HTH

--Geoff

Re: [mp1] Method handler that eventually seems to "forget" it"s a method handler

am 02.02.2005 16:11:29 von Martin Moss

I've seen this problem and never got to the bottom of
it, on a redhat box with 5.8.3 (I think) and same
apache and mod_perl,

Marty




--- Andrew Green wrote:
> Hi,
>
> I seem to have a bizarre problem with method
> handlers on my setup. I
> have a set of different handlers, all of which are
> method handlers so
> that I can easily inherit shared code across a
> collection of different
> installations of my application on the same server.
>
> The first handler to get invoked is a
> PerlTransHandler -- everything
> works fine (or at least seems to) for quite some
> time, but then the
> handler begins "forgetting" that it's a method
> handler, and instead of
> the class being passed before $r, $r becomes the
> first thing passed.
> At least, that seems to be what's happening. Is
> this a known problem?
>
> My setup is as follows:
>
> Perl 5.8.0 (Red Hat EL 3 default)
> Apache/1.3.29
> mod_perl/1.29
>
>
> Here's what I imagine to be the relevant bits of
> httpd.conf:
>
> MinSpareServers 10
> MaxSpareServers 20
> StartServers 10
> MaxClients 60
> MaxRequestsPerChild 1000
> ...
>
> PerlTransHandler MyApp::MyInstall::Dispatcher
> ...
>
>
> Here's the relevant bits of Dispatcher.pm:
>
> package MyApp::MyInstall::Dispatcher;
>
> use strict;
> use Apache::Constants qw(OK DECLINED NOT_FOUND
> REDIRECT FORBIDDEN);
> use Apache::URI;
>
> our @ISA = qw(MyApp::Core::Dispatcher);
>
> 1;
>
> ####
>
> sub handler ($$) {
>
> my ($class,$r) = @_;
> return DECLINED unless ($r->is_initial_req());
> ...
>
>
> And here's the error (that only starts appearing
> after the server's
> been running for a while:
>
> Can't call method "is_initial_req" on an undefined
> value...
>
> The error then points to the line quoted above. Of
> course, Apache
> never gets to other handlers later in the sequence,
> so I can't easily
> see whether the problem is limited to TransHandlers,
> or whether all my
> method handlers would stop acting as such.
> Restarting the server makes
> the problem go away -- for a while!
>
> I'd really like to avoid having to upgrade/change
> Perl or mod_perl if
> at all possible. Nonetheless, any help, advice or
> guidance anyone can
> provide would be very much appreciated.
>
> Cheers,
> Andrew.
>





___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Re: [mp1] Method handler that eventually seems to "forget" it"s a method handler

am 02.02.2005 16:14:49 von Martin Moss

I tried ->handler in my configs, made no difference.
I was doing a 'require' in a startup script if that
makes any difference. Haven't seen this issue with
simillar code anywhere else..

Marty

--- Geoffrey Young wrote:

>
> >
> > PerlTransHandler MyApp::MyInstall::Dispatcher
>
> make that
>
> PerlTransHandler
> MyApp::MyInstall::Dispatcher->handler
>
> and see if that helps. you should also be
> preloading via
>
> PerlModule MyApp::MyInstall::Dispatcher
>
> or in a startup.pl.
>
> HTH
>
> --Geoff
>





___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Re: [mp1] Method handler that eventually seems to "forget" it"s amethod handler

am 02.02.2005 16:25:51 von Andrew Green

On Wed, 02 Feb 2005 10:10:56 -0500, Geoffrey Young wrote:

> PerlTransHandler MyApp::MyInstall::Dispatcher->handler
>
> and see if that helps.

I'll give that a go and see. Is the following also kosher, then?

$r->push_handlers(
PerlCleanupHandler => MyApp::MyInstall::Cleaner->handler
);


> you should also be preloading via
>
> PerlModule MyApp::MyInstall::Dispatcher
>
> or in a startup.pl.

Yes, I am -- sorry I forgot to mention this -- in a startup.pl, as
follows:

use MyApp::Core::Dispatcher ();
use MyApp::MyInstall::Dispatcher ();


Thanks for your help.

Cheers,
Andrew.
--
::
article seven Andrew Green
automatic internet andrew@article7.co.uk | www.article7.co.uk

Re: [mp1] Method handler that eventually seems to "forget" it"s amethod handler

am 02.02.2005 16:37:18 von Geoffrey Young

Andrew Green wrote:
> On Wed, 02 Feb 2005 10:10:56 -0500, Geoffrey Young wrote:
>
>
>> PerlTransHandler MyApp::MyInstall::Dispatcher->handler
>>
>>and see if that helps.
>
>
> I'll give that a go and see. Is the following also kosher, then?
>
> $r->push_handlers(
> PerlCleanupHandler => MyApp::MyInstall::Cleaner->handler
> );

sorry, no - you can't currently push a method handler like that. see the

* method handler cached-CVs

entry in the STATUS file that ships with mod_perl-1.0 for some relevant links.

--Geoff

Re: [mp1] Method handler that eventually seems to "forget" it"s amethod handler

am 02.02.2005 16:40:26 von Geoffrey Young

>>I'll give that a go and see. Is the following also kosher, then?
>>
>> $r->push_handlers(
>> PerlCleanupHandler => MyApp::MyInstall::Cleaner->handler
>> );
>
>
> sorry, no - you can't currently push a method handler like that. see the
>
> * method handler cached-CVs
>
> entry in the STATUS file that ships with mod_perl-1.0 for some relevant links.

and for those that don't go and read the links, while the above form isn't
valid you should be able to use this instead.

$r->push_handlers(
PerlCleanupHandler => 'MyApp::MyInstall::Cleaner->handler'
);

(note the quotes)

--Geoff