diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index e1586923c80028..380d31ed5d9aa7 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -172,8 +172,10 @@ def readline BUFSIZE = 1024 * 16 def rbuf_fill - case rv = @io.read_nonblock(BUFSIZE, exception: false) + tmp = @rbuf.empty? ? @rbuf : nil + case rv = @io.read_nonblock(BUFSIZE, tmp, exception: false) when String + return if rv.equal?(tmp) @rbuf << rv rv.clear return