diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index f669055..0735f0c 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -576,6 +576,7 @@ sub quit_respond { sub disconnect { my $self = shift; $self->run_hooks("disconnect"); + $self->connection->notes(disconnected => 1); $self->reset_transaction; } diff --git a/lib/Qpsmtpd/TcpServer.pm b/lib/Qpsmtpd/TcpServer.pm index 07d8d16..de3504f 100644 --- a/lib/Qpsmtpd/TcpServer.pm +++ b/lib/Qpsmtpd/TcpServer.pm @@ -115,6 +115,10 @@ sub read_input { alarm $timeout; } alarm(0); + return if $self->connection->notes('disconnected'); + $self->reset_transaction; + $self->run_hooks('disconnect'); + $self->connection->notes(disconnected => 1); } sub respond { diff --git a/lib/Qpsmtpd/TcpServer/Prefork.pm b/lib/Qpsmtpd/TcpServer/Prefork.pm index 28f60dc..2728cea 100644 --- a/lib/Qpsmtpd/TcpServer/Prefork.pm +++ b/lib/Qpsmtpd/TcpServer/Prefork.pm @@ -35,6 +35,11 @@ sub read_input { or $self->respond(502, "command unrecognized: '$_'"); alarm $timeout; } + unless ($self->connection->notes('disconnected')) { + $self->reset_transaction; + $self->run_hooks('disconnect'); + $self->connection->notes(disconnected => 1); + } }; if ($@ =~ /^disconnect_tcpserver/) { die "disconnect_tcpserver";