lxc enter: fix read from non-blocking web socket
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 8 Jun 2018 08:20:21 +0000 (10:20 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 8 Jun 2018 09:42:22 +0000 (11:42 +0200)
PVE/APIClient/Commands/lxc.pm

index 6c9603a..879d7c3 100644 (file)
@@ -202,7 +202,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;
        };
 
@@ -318,7 +320,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 {