On Thu, 3 Feb 2000, Oleg Bartunov wrote:

[snipped]
> > > Stas, are you sure DESTROY executed when children died ?
> > > I'm using ApacheDBI and have problem with DESTROY when I use
> > > finish or disconnect methods.
> > 
> > Of course! This works for me:
> > die.pl
> > --------
> > use MyRun;
> > print "Content-type: text/plain\n\n";
> > print "hi\n";
> > my $obj = new MyRun;
> > die "dying...";
> > print "End of program\n";
> > 
> > MyRun.pm
> > --------
> > package MyRun;
> > sub new{  return bless {}, shift;}
> > DESTROY{ print STDERR "destructor was called\n";}
> > 1;
> 
> Such simple DESTROY works for me also.
> 
> > 
> > The disconnect method shouldn't work as it gets overriden by Apache::DBI
> > with NOP. However finish() is supposed to work.
> 
> I'm not sure it works:
> 
> sub disconnect {
>  my $self = shift;
>  $self->sth_finish;
>  warn "STH finished...\n";
>  $self->{dbh}->disconnect;
>  warn "DB disconnected...\n";
> }
> 
> sub sth_finish {
>  my $self = shift;
>  foreach my $sth (keys %query) {
>        $self->{$sth}->finish;
>  }
> }
> 
> sub DESTROY {
>   my $self = shift;
>   $self->disconnect;
>   print STDERR "DB requests:PID:",$$,':', $self->total_db_requests(),"\n";
> }
> I never get  debug messages in error log. But If I comment
> all calling of methods I got what I expected.
> sub disconnect {
>  my $self = shift;
> # $self->sth_finish;
>  warn "STH finished...\n";
> # $self->{dbh}->disconnect;
>  warn "DB disconnected...\n";
> }
> 
> sub DESTROY {
>   my $self = shift;
>   $self->disconnect;
>   print STDERR "DB requests:PID:",$$,':', $self->total_db_requests(),"\n";
> }
> 
> This behaivour doesn't depends whether or not I use ApacheDBI

So it's DBI. Did you try to add debug messages to DBI module? in finish
and disconnect? Actually in the appropriate DBD module of your db.

What are the results? Did you try to ask at the dbi-users mailing list?

Please summarize back to list or me, if you have solved it. This is an
important issue that has to be documented. Thanks!

> It seems DESTROY doesnt' executed when apache+mod_perl chidlren get
> killed :-) 

It depends on how do you kill it. kill -9 is untrappable so you cannot do
a thing about it. If it's any other kill signal you can trap it with %SIG
and call the cleanup code. Does it help?

_______________________________________________________________________
Stas Bekman    mailto:[EMAIL PROTECTED]      http://www.stason.org/stas
Perl,CGI,Apache,Linux,Web,Java,PC     http://www.stason.org/stas/TULARC
perl.apache.org    modperl.sourcegarden.org   perlmonth.com    perl.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com

Reply via email to