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:
parent
96aa5ba171
commit
5c3bd220aa
@ -576,6 +576,7 @@ sub quit_respond {
|
|||||||
sub disconnect {
|
sub disconnect {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->run_hooks("disconnect");
|
$self->run_hooks("disconnect");
|
||||||
|
$self->connection->notes(disconnected => 1);
|
||||||
$self->reset_transaction;
|
$self->reset_transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,10 @@ sub read_input {
|
|||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
}
|
}
|
||||||
alarm(0);
|
alarm(0);
|
||||||
|
return if $self->connection->notes('disconnected');
|
||||||
|
$self->reset_transaction;
|
||||||
|
$self->run_hooks('disconnect');
|
||||||
|
$self->connection->notes(disconnected => 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub respond {
|
sub respond {
|
||||||
|
@ -35,6 +35,11 @@ sub read_input {
|
|||||||
or $self->respond(502, "command unrecognized: '$_'");
|
or $self->respond(502, "command unrecognized: '$_'");
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
}
|
}
|
||||||
|
unless ($self->connection->notes('disconnected')) {
|
||||||
|
$self->reset_transaction;
|
||||||
|
$self->run_hooks('disconnect');
|
||||||
|
$self->connection->notes(disconnected => 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if ($@ =~ /^disconnect_tcpserver/) {
|
if ($@ =~ /^disconnect_tcpserver/) {
|
||||||
die "disconnect_tcpserver";
|
die "disconnect_tcpserver";
|
||||||
|
Loading…
Reference in New Issue
Block a user