Run hook_reset_transaction after all connections

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.
This commit is contained in:
jaredj 2009-02-28 15:13:46 +08:00 committed by Ask Bjørn Hansen
parent 96aa5ba171
commit 5c3bd220aa
3 changed files with 10 additions and 0 deletions

View File

@ -576,6 +576,7 @@ sub quit_respond {
sub disconnect {
my $self = shift;
$self->run_hooks("disconnect");
$self->connection->notes(disconnected => 1);
$self->reset_transaction;
}

View File

@ -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 {

View File

@ -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";