From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C722B1FF15E for <inbox@lore.proxmox.com>; Tue, 8 Apr 2025 16:20:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 249FC1F559; Tue, 8 Apr 2025 16:20:50 +0200 (CEST) From: Fiona Ebner <f.ebner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Tue, 8 Apr 2025 16:20:12 +0200 Message-Id: <20250408142014.86344-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250408142014.86344-1-f.ebner@proxmox.com> References: <20250408142014.86344-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.036 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH http-server 1/3] anyevent: disconnect: check that handle is still defined before calling shutdown() X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Commit 07e56cc ("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> --- src/PVE/APIServer/AnyEvent.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 9b18ee2..3f8642b 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -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 { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel