Merge pull request #106 from msimerson/disconnect

SMTP: don't create new Transaction at disconnect
This commit is contained in:
Jared Johnson 2014-09-16 20:17:13 -05:00
commit e50fee88c0

View File

@ -131,12 +131,14 @@ sub connect_respond {
sub transaction { sub transaction {
my $self = shift; my $self = shift;
return $self->{_transaction} || $self->reset_transaction(); return $self->{_transaction} || $self->reset_transaction;
} }
sub reset_transaction { sub reset_transaction {
my $self = shift; my $self = shift;
$self->run_hooks("reset_transaction") if $self->{_transaction}; if ($self->{_transaction}) {
$self->run_hooks('reset_transaction');
};
return $self->{_transaction} = Qpsmtpd::Transaction->new(); return $self->{_transaction} = Qpsmtpd::Transaction->new();
} }
@ -591,7 +593,7 @@ sub vrfy_respond {
elsif ($rc == DENY) { elsif ($rc == DENY) {
$msg->[0] ||= "Access Denied"; $msg->[0] ||= "Access Denied";
$self->respond(554, @$msg); $self->respond(554, @$msg);
$self->reset_transaction(); $self->reset_transaction;
return 1; return 1;
} }
elsif ($rc == OK) { elsif ($rc == OK) {
@ -631,7 +633,8 @@ sub disconnect {
my $self = shift; my $self = shift;
$self->run_hooks("disconnect"); $self->run_hooks("disconnect");
$self->connection->notes(disconnected => 1); $self->connection->notes(disconnected => 1);
$self->reset_transaction; $self->run_hooks('reset_transaction') if $self->{_transaction};
return;
} }
sub data { sub data {
@ -647,13 +650,13 @@ sub data_respond {
elsif ($rc == DENY) { elsif ($rc == DENY) {
$msg->[0] ||= "Message denied"; $msg->[0] ||= "Message denied";
$self->respond(554, @$msg); $self->respond(554, @$msg);
$self->reset_transaction(); $self->reset_transaction;
return 1; return 1;
} }
elsif ($rc == DENYSOFT) { elsif ($rc == DENYSOFT) {
$msg->[0] ||= "Message denied temporarily"; $msg->[0] ||= "Message denied temporarily";
$self->respond(451, @$msg); $self->respond(451, @$msg);
$self->reset_transaction(); $self->reset_transaction;
return 1; return 1;
} }
elsif ($rc == DENY_DISCONNECT) { elsif ($rc == DENY_DISCONNECT) {