Skip to content

Commit

Permalink
Fix hang in IO::Socket::INET.lines
Browse files Browse the repository at this point in the history
Fixes R#1721 #1721

When we read zero bytes we ask the decoder for all it's got, which gives
us an empty string and we infiniloop "reading" all the empty strings.

Fix by checking if the decoder is empty before grabbing the last bytes.
  • Loading branch information
zoffixznet committed Apr 9, 2018
1 parent 518f2c3 commit 6e37c7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/IO/Socket.pm6
Expand Up @@ -76,7 +76,8 @@ my role IO::Socket {
$line = $!decoder.consume-line-chars(:chomp);
last if $line.DEFINITE;
if $read == 0 {
$line = $!decoder.consume-line-chars(:chomp, :eof);
$line = $!decoder.consume-line-chars(:chomp, :eof)
unless $!decoder.is-empty;
last;
}
}
Expand Down

0 comments on commit 6e37c7f

Please sign in to comment.