On Wed, 2 Feb 2000, Stas Bekman wrote:

> Date: Wed, 2 Feb 2000 22:03:38 +0200 (IST)
> From: Stas Bekman <[EMAIL PROTECTED]>
> To: Oleg Bartunov <[EMAIL PROTECTED]>
> Cc: mod_perl list <[EMAIL PROTECTED]>
> Subject: Re: Using network appliance Filer with modperl
> 
> On Wed, 2 Feb 2000, Oleg Bartunov wrote:
> 
> > On Wed, 2 Feb 2000, Stas Bekman wrote:
> > 
> > > Date: Wed, 2 Feb 2000 20:21:20 +0200 (IST)
> > > From: Stas Bekman <[EMAIL PROTECTED]>
> > > To: Pascal Eeftinck <[EMAIL PROTECTED]>
> > > Cc: mod_perl list <[EMAIL PROTECTED]>
> > > Subject: Re: Using network appliance Filer with modperl
> > > # DESTROY makes all kinds of cleanups if the fuctions were interuppted
> > > # before their completion and haven't had a chance to make a clean up.
> > > ###########
> > > sub DESTROY{
> > >   my $self = shift;
> > > 
> > >   $self->sql_unlock_tables() if defined $self->{lock};
> > > 
> > >   $self->{sth}->finish     if defined $self->{sth} and $self->{sth};
> > >   $self->{dbh}->disconnect if defined $self->{dbh} and $self->{dbh};
> > > 
> > > } # end of sub DESTROY
> > 
> > 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


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


Regards,

        Oleg


> 
> _______________________________________________________________________
> 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
> 

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: [EMAIL PROTECTED], http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

Reply via email to