fix #3807: don't attempt response on closed handle

if a client closes the connection while the API server is
waiting/stalling here, the handle will disappear, and sending a response
is no longer possible.

(this issue is only cosmetic, but if such clients are a regular
occurrence it might get quite noisy in the logs)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-12-29 12:15:34 +01:00 committed by Thomas Lamprecht
parent baf8c8dc0d
commit e12e46c979

View File

@ -361,6 +361,7 @@ sub response {
} elsif ($delay && $delay > 0) {
my $w; $w = AnyEvent->timer(after => $delay, cb => sub {
undef $w; # delete reference
return if !$reqstate->{hdl}; # already disconnected
$reqstate->{hdl}->push_write($res);
$self->finish_response($reqstate);
});