From 6e37c7f048a06d2ee8304463f2ca2cfc138d0798 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Mon, 9 Apr 2018 23:56:06 +0000 Subject: [PATCH] Fix hang in IO::Socket::INET.lines Fixes R#1721 https://github.com/rakudo/rakudo/issues/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. --- src/core/IO/Socket.pm6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/IO/Socket.pm6 b/src/core/IO/Socket.pm6 index 178e067324d..5578fe03f2d 100644 --- a/src/core/IO/Socket.pm6 +++ b/src/core/IO/Socket.pm6 @@ -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; } }