From feab782a0abaad8f068ec95d7157429a3e96b9db Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 22 Jun 2012 18:16:43 -0400 Subject: [PATCH] Transaction.pm: added debugging messages for DESTROY --- lib/Qpsmtpd/Transaction.pm | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 0dabffa..4283d29 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -2,14 +2,16 @@ package Qpsmtpd::Transaction; use Qpsmtpd; @ISA = qw(Qpsmtpd); use strict; +use warnings; + use Qpsmtpd::Utils; use Qpsmtpd::Constants; + +use IO::File qw(O_RDWR O_CREAT); use Socket qw(inet_aton); use Sys::Hostname; use Time::HiRes qw(gettimeofday); -use IO::File qw(O_RDWR O_CREAT); - sub new { start(@_) } sub start { @@ -116,6 +118,9 @@ sub body_spool { } $self->{_body_start} = $self->{_header_size}; } + else { + $self->log(LOGERROR, "no message body"); + } $self->{_body_array} = undef; } @@ -227,10 +232,20 @@ sub DESTROY { # would we save some disk flushing if we unlinked the file before # closing it? - undef $self->{_body_file} if $self->{_body_file}; - if ($self->{_filename} and -e $self->{_filename}) { - unlink $self->{_filename} or $self->log(LOGERROR, "Could not unlink ", $self->{_filename}, ": $!"); - } + $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 ( unlink $self->{_filename} ) { + $self->log(LOGDEBUG, "unlinked ", $self->{_filename} ); + } + else { + $self->log(LOGERROR, "Could not unlink ", $self->{_filename}, ": $!"); + } + } # These may not exist if ( $self->{_temp_files} ) {