[pve-devel] [PATCH pve-client 6/7] lxc enter: fix read from non-blocking web socket

Dietmar Maurer dietmar at proxmox.com
Fri Jun 8 11:25:56 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/APIClient/Commands/lxc.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
index 4988bf2..f981c11 100644
--- a/PVE/APIClient/Commands/lxc.pm
+++ b/PVE/APIClient/Commands/lxc.pm
@@ -203,7 +203,9 @@ __PACKAGE__->register_method ({
 
 	my $wb_socket_read_available_bytes = sub {
 	    my $nr = $web_socket->sysread($wsbuf, $max_payload_size, length($wsbuf));
-	    die "web socket read error - $!\n" if $nr < 0;
+	    if (!defined($nr) && !($! == EINTR || $! == EAGAIN)) {
+		die "web socket read error - $!\n";
+	    }
 	    return $nr;
 	};
 
@@ -319,7 +321,7 @@ __PACKAGE__->register_method ({
 
 			    my $nr = $wb_socket_read_available_bytes->();
 			    if (!defined($nr)) {
-				die "web socket read error $!\n";
+				# wait
 			    } elsif ($nr == 0) {
 				return; # EOF
 			    } else {
-- 
2.11.0



More information about the pve-devel mailing list