Transaction.pm: added debugging messages for DESTROY

This commit is contained in:
Matt Simerson 2012-06-22 18:16:43 -04:00
parent d5ccedd37e
commit 3b9479a497

View File

@ -2,14 +2,16 @@ package Qpsmtpd::Transaction;
use Qpsmtpd; use Qpsmtpd;
@ISA = qw(Qpsmtpd); @ISA = qw(Qpsmtpd);
use strict; use strict;
use warnings;
use Qpsmtpd::Utils; use Qpsmtpd::Utils;
use Qpsmtpd::Constants; use Qpsmtpd::Constants;
use IO::File qw(O_RDWR O_CREAT);
use Socket qw(inet_aton); use Socket qw(inet_aton);
use Sys::Hostname; use Sys::Hostname;
use Time::HiRes qw(gettimeofday); use Time::HiRes qw(gettimeofday);
use IO::File qw(O_RDWR O_CREAT);
sub new { start(@_) } sub new { start(@_) }
sub start { sub start {
@ -116,6 +118,9 @@ sub body_spool {
} }
$self->{_body_start} = $self->{_header_size}; $self->{_body_start} = $self->{_header_size};
} }
else {
$self->log(LOGERROR, "no message body");
}
$self->{_body_array} = undef; $self->{_body_array} = undef;
} }
@ -227,9 +232,19 @@ sub DESTROY {
# would we save some disk flushing if we unlinked the file before # would we save some disk flushing if we unlinked the file before
# closing it? # closing it?
undef $self->{_body_file} if $self->{_body_file}; $self->log(LOGDEBUG, sprintf( "DESTROY called by %s, %s, %s", (caller) ) );
if ( $self->{_body_file} ) {
undef $self->{_body_file};
};
if ($self->{_filename} and -e $self->{_filename}) { if ($self->{_filename} and -e $self->{_filename}) {
unlink $self->{_filename} or $self->log(LOGERROR, "Could not unlink ", $self->{_filename}, ": $!"); if ( unlink $self->{_filename} ) {
$self->log(LOGDEBUG, "unlinked ", $self->{_filename} );
}
else {
$self->log(LOGERROR, "Could not unlink ", $self->{_filename}, ": $!");
}
} }
# These may not exist # These may not exist