Skip to content

Commit

Permalink
Run hook_reset_transaction after all connections
Browse files Browse the repository at this point in the history
This makes hook_reset_transaction a bit more useful by running it on
disconnections.  It also ensures that hook_disconnect runs when the
client disconnects without QUITing.
  • Loading branch information
jaredj authored and abh committed Sep 15, 2010
1 parent 96aa5ba commit 5c3bd22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Qpsmtpd/SMTP.pm
Expand Up @@ -576,6 +576,7 @@ sub quit_respond {
sub disconnect {
my $self = shift;
$self->run_hooks("disconnect");
$self->connection->notes(disconnected => 1);
$self->reset_transaction;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Qpsmtpd/TcpServer.pm
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions lib/Qpsmtpd/TcpServer/Prefork.pm
Expand Up @@ -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";
Expand Down

0 comments on commit 5c3bd22

Please sign in to comment.