perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Handler leakage
Date Mon, 02 Mar 2009 16:58:11 GMT
Hi,

I have just stumbled on the following behavior.

httpd.conf:

<Perl>
{
  package My::Object;
  sub handler : method {
    my ($self, $r)=@_;

    $r->push_handlers(PerlLogHandler =>
                      sub {
                        $self->doit;
                      });
  }

  sub DESTROY {...}
}

$My::XX=My::Object->new(...);
</Perl>

<Location /handler>
  PerlResponseHandler $My::XX->handler
  ...
</Location>
<Location /quit>
  PerlResponseHandler "sub {undef $My::XX; $_[0]->child_terminate; 0;}"
  ...
</Location>

If /quit is called the $My::XX object is undefined. So the one and only 
reference to the global object is released and it has to be destroyed. 
That works but only if /handler hasn't been called before.

The reason can be found in modperl_handler.c. Each time /handler is 
called a new closure is stored in $PL_modglobal{ANONSUB}{$id}. 
Unfortunately the closure is never deleted from the hash I believe. So 
since $self is in the pad each time /handler is called a reference is 
added to $My::XX from the closure.

I think that analysis is correct (not very sure) but I don't really know 
how to fix it.

Any hints, ideas?

Torsten

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message