mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-04-30 04:21:02 +00:00
anyevent: disconnect: check that handle is still defined before calling shutdown()
Commit07e56cc
("fix unexpected EOF for client when closing TLS session") added a call to stoptls() before the call to shutdown() for the handle's file descriptor. However, the documentation for AnyEvent[0] mentions for stoptls(): > This method may invoke callbacks (and therefore the handle might be > destroyed after it returns). Therefore, it is necessary to check that the handle is still defined before calling shutdown(). Otherwise, this can result in a warning: > Can't use an undefined value as a symbol reference at > /usr/share/perl5/PVE/APIServer/AnyEvent.pm line 150. as reported in the community forum [1]. The debug print message for closing the file handle is split up, because part of it relies on the file handle to be defined. [0]: https://metacpan.org/pod/AnyEvent::Handle#$handle-%3Estoptls [1]: https://forum.proxmox.com/threads/164744/ Fixes:07e56cc
("fix unexpected EOF for client when closing TLS session") Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Link: https://lore.proxmox.com/20250408142014.86344-2-f.ebner@proxmox.com
This commit is contained in:
parent
a8ff92cbb0
commit
0ec627cff1
@ -146,8 +146,11 @@ sub client_do_disconnect {
|
||||
$hdl->on_read(undef);
|
||||
$hdl->on_eof(undef);
|
||||
|
||||
$hdl->stoptls();
|
||||
shutdown($hdl->{fh}, 1);
|
||||
$self->dprint("CLOSE FH" . $hdl->{fh}->fileno());
|
||||
|
||||
$hdl->stoptls(); # can invoke callbacks and destroy the handle
|
||||
|
||||
shutdown($hdl->{fh}, 1) if defined($hdl) && defined($hdl->{fh});
|
||||
};
|
||||
|
||||
if (my $proxyhdl = delete $reqstate->{proxyhdl}) {
|
||||
@ -170,7 +173,7 @@ sub client_do_disconnect {
|
||||
|
||||
$self->{conn_count}--;
|
||||
|
||||
$self->dprint("CLOSE FH" . $hdl->{fh}->fileno() . " CONN$self->{conn_count}");
|
||||
$self->dprint("DISCONNECT CONN$self->{conn_count}");
|
||||
}
|
||||
|
||||
sub finish_response {
|
||||
|
Loading…
Reference in New Issue
Block a user