From 9ce5e2e1e7effa984b7e619d6a9d838f24a8b36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urb=C3=A1n=20D=C3=A1niel?= Date: Wed, 13 Jun 2018 13:33:35 +0200 Subject: [PATCH] Buffering bug fix. --- .gitignore | 1 + lib/fluent/plugin/named_pipe/fifo.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index bac9a1f..0608beb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage .yardoc .ruby-version pkg/* +.idea diff --git a/lib/fluent/plugin/named_pipe/fifo.rb b/lib/fluent/plugin/named_pipe/fifo.rb index d28a4dd..922a753 100644 --- a/lib/fluent/plugin/named_pipe/fifo.rb +++ b/lib/fluent/plugin/named_pipe/fifo.rb @@ -31,6 +31,12 @@ def open end def readline + if nil != (idx = @buf.index("\n")) + line = @buf[0, idx + 1] + @buf = @buf[idx + 1, @buf.length - line.length] + return line + end + res = IO.select([@pipe], [], [], READ_TIMEOUT) return nil if res.nil?