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

Reply via email to