I'm hoping someone can explain this one to me. I have a virtual host set up like so:
<<VHOST


# This declares Apache::Webquills::InitSession::handler
PerlRequire /var/www/html/webquills/offline/wq_startup.pl

<VirtualHost *>
ServerName www.example.com
ServerAlias example.com
ServerPath /test
DocumentRoot /var/www/html/test

PerlHeaderParserHandler Apache::Webquills::InitSession

<Directory /var/www/html/test>
    AllowOverride All
    Options Indexes FollowSymLinks MultiViews ExecCGI
    Order allow,deny
    Allow from all
        
        SetHandler perl-script
        PerlHandler Apache::Registry

</Directory>
</VirtualHost>
VHOST

Now here is the thing. The PerlHeaderParserHandler executes TWICE for every request. The second time through is apparently a different Apache object from the first, as when I write to $r->notes, only the values from the second execution are visible to the content handler.

Now, if I comment out the PerlHeaderParserHandler line in the conf file, the handler never executes at all (which is expected), so it isn't getting pushed onto handlers from somewhere else.

The handler code looks something like this:
<<CODE

use vars qw( $stupid );
my $DEBUG =1;

sub handler
{
        # Always call 'instance' so as not to clobber params.
    my ($r) = Apache::Request->instance(shift);
        
        # Insane bug I cannot track causes this handler to execute twice
        # for each request. It's driving me nuts.
        if ( $stupid++ ) {
                $r->log_error($r->current_callback . " executed twice! Argh!");
                $r->notes(HAND2 => "HAND2");
                $r->pnotes(HAND2 => "HAND2");
        } else {
                $r->log_error($r->current_callback . " executed once.");
                $r->notes(HAND1 => "HAND1");
                $r->pnotes(HAND1 => "HAND1");
                return DECLINED;
        }#END if
        
## SNIP -- Some standard Apache::Session stuff happens here.
## This "Log Handler" actually unties and closes the session.
## It executes just fine.
        $r->push_handlers('PerlLogHandler', \&closer);


if ( $DEBUG ) { $r->log_error("$$: ". $r->current_callback); $r->log_error("$$: ". $r->is_main ? "is main" : "not main"); $r->log_error("$$: ". $r->is_initial_req ? "is initial" : "not initial"); }#END if

    return OK;
}

CODE

The log messages get me this:
<<LOG

[Fri Mar 28 17:27:06 2003] [error] PerlHeaderParserHandler executed once.
[Fri Mar 28 17:27:06 2003] [error] PerlHeaderParserHandler executed twice! Argh!
[Fri Mar 28 17:27:06 2003] [error] 19914: PerlHeaderParserHandler
[Fri Mar 28 17:27:06 2003] [error] is main
[Fri Mar 28 17:27:06 2003] [error] is initial


LOG

And the content handler sees values for HAND2 but not for HAND1.

Why is this thing running twice, and how can I make it stop??? I hope someone can hit me over the head with a clue-stick, because this thing is driving me completely bananas!

All help is greatly appreciated,
Vince Veselosky
http://ice.control-escape.com







Reply via email to