From 521a6f3f9e1a2dd5b4db85eee45278ff6f39a35a Mon Sep 17 00:00:00 2001
From: Matt Sergeant <matt@sergeant.org>
Date: Fri, 3 Aug 2007 20:16:01 +0000
Subject: [PATCH] Fix bug which breaks queue plugins that implement
 continuations

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@764 958fd67b-6ff1-0310-b445-bb7760255be9
---
 lib/Qpsmtpd/SMTP.pm | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm
index 6b89e11..559f71b 100644
--- a/lib/Qpsmtpd/SMTP.pm
+++ b/lib/Qpsmtpd/SMTP.pm
@@ -719,18 +719,18 @@ sub data_post_respond {
   elsif ($rc == DENY) {
     $msg->[0] ||= "Message denied";
     $self->respond(552, @$msg);
+    # DATA is always the end of a "transaction"
+    return $self->reset_transaction;
   }
   elsif ($rc == DENYSOFT) {
     $msg->[0] ||= "Message denied temporarily";
     $self->respond(452, @$msg);
+    # DATA is always the end of a "transaction"
+    return $self->reset_transaction;
   } 
   else {
     $self->queue($self->transaction);
   }
-
-  # DATA is always the end of a "transaction"
-  return $self->reset_transaction;
-
 }
 
 sub getline {
@@ -765,6 +765,10 @@ sub queue_pre_respond {
 
 sub queue_respond {
   my ($self, $rc, $msg, $args) = @_;
+  
+  # reset transaction if we queued the mail
+  return $self->reset_transaction;
+  
   if ($rc == DONE) {
     return 1;
   }