SetHandlers question, Phase II

SetHandlers question, Phase II

am 15.10.2008 09:14:41 von aw

Help ! (please)

To make a long story short, I created an Apache/mod_perl module for AAA,
which after major help from Torsten Foertsch now works fine... on one
system, but not on another relatively similar one. The module is called
AUTH::StarLogCookie.

the critical line is line 419 of the module, which says :

$r->set_handlers(PerlFixupHandler => \{$_[0]->handler('modperl')});

On one system, this works fine, but on the other one it brings this
error in the Apache log :
[Tue Oct 14 18:50:26 2008] [error] [client 84.158.163.207] Can't locate
object method "handler" via package "AUTH::StarLogCookie" at
/usr/local/lib/apache2/perllib/AUTH/StarLogCookie.pm line 419.\n

The system where it works fine is this one :
ok-system (Intel-based) :
[Tue Oct 14 16:58:47 2008] [notice] Apache/2.2.3 (Debian) DAV/2
SVN/1.4.2 mod_jk/1.2.18 PHP/4.4.4-8+etch4 mod_ssl/2.2.3 OpenSSL/0.9.8c
mod_perl/2.0.2 Perl/v5.8.8 configured -- resuming normal operations

and the one where it brings the error is this one :
bad-system (Apple PPC-based) :
[Tue Oct 14 18:59:43 2008] [notice] Apache/2.2.9 (Debian) DAV/2
mod_jk/1.2.26 mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal
operations

There is a difference between the versions of Apache, perl and mod_perl,
so my question is : can this problem be attributed to these version
differences ?

The funny thing is, the way I understand that code above is to mean :
"take a reference to the piece of code between the curly brackets, and
pass that code reference as the 2d argument to $r->set_handlers()".
But the error message seems to indicate that perl is actually trying to
execute "$_[0]->handler()" at that point, no ?

Thanks.

Re: SetHandlers question, Phase II

am 15.10.2008 09:36:41 von Clinton Gormley

> $r->set_handlers(PerlFixupHandler => \{$_[0]->handler('modperl')});

> The funny thing is, the way I understand that code above is to mean :
> "take a reference to the piece of code between the curly brackets, and
> pass that code reference as the 2d argument to $r->set_handlers()".
> But the error message seems to indicate that perl is actually trying to
> execute "$_[0]->handler()" at that point, no ?
>

Actually, this code takes a reference to the value returned when you run
the code between the curlies.


What I can't figure out is why it works at all in one of your systems :)

I think you're wanting:

 $r->set_handlers(PerlFixupHandler => sub {$_[0]->handler('modperl')});

hth

Clint

Re: SetHandlers question, Phase II

am 15.10.2008 10:06:23 von aw

Thanks.
Duh.

Clinton Gormley wrote:
>> $r->set_handlers(PerlFixupHandler => \{$_[0]->handler('modperl')});
> 
>> The funny thing is, the way I understand that code above is to mean :
>> "take a reference to the piece of code between the curly brackets, and
>> pass that code reference as the 2d argument to $r->set_handlers()".
>> But the error message seems to indicate that perl is actually trying to
>> execute "$_[0]->handler()" at that point, no ?
>>
>
> Actually, this code takes a reference to the value returned when you run
> the code between the curlies.
>
>
> What I can't figure out is why it works at all in one of your systems :)
>
> I think you're wanting:
>
>  $r->set_handlers(PerlFixupHandler => sub {$_[0]->handler('modperl')});
>
Yes. That works.
Thank you, my mistake. Shows how easily I get confused when trying to
do anything even remotely sophisticated with perl references.

Now that you pointed this out, I also don't understand why it is running
on the other system. It would be interesting to figure out what the
returned value of that call is (was) (probably the old value of
handler()), and why it is then different between these two systems also.
The module is exactly the same in both cases, and it is called in the
same circumstances, from a section configured in the same way.
Yes, I know, there must be a difference. Hmm.

Re: SetHandlers question, Phase II

am 15.10.2008 10:56:39 von torsten.foertsch

On Wed 15 Oct 2008, André Warnier wrote:
> > I think you're wanting:
> >
> > ï»=BF     $r->set_handlers(PerlFixupHandler =3D> sub
> > {$_[0]->handler('modperl')});
>
> Yes.  That works.

Better to return something sane from the handler:

sub {$_[0]->handler('modperl');0} # 0==Apache2::Const::OK

Also consider push_handlers instead of set_handlers. In case other=20
modules already have set a fixup handler.

Torsten

=2D-
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net