Skip to content

Commit

Permalink
make has_skipped_line local variable
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom committed Jun 12, 2024
1 parent bf73efe commit 05e7caf
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,6 @@ def initialize(from_encoding, encoding, log, max_line_size=nil)
@eol = "\n".encode(from_encoding).freeze
@max_line_size = max_line_size
@was_long_line = false
@has_skipped_line = false
@log = log
end

Expand Down Expand Up @@ -1048,7 +1047,7 @@ def convert(s)

def read_lines(lines)
idx = @buffer.index(@eol)
@has_skipped_line = false
has_skipped_line = false

until idx.nil?
# Using freeze and slice is faster than slice!
Expand All @@ -1066,7 +1065,7 @@ def read_lines(lines)
@log.warn "received line length is longer than #{@max_line_size}"
@log.debug("skipped line: ") { convert(rbuf).chomp }
@was_long_line = false
@has_skipped_line = true
has_skipped_line = true
next
end

Expand All @@ -1080,17 +1079,14 @@ def read_lines(lines)
if is_long_line
@buffer.clear
@was_long_line = true
@has_skipped_line = true
end

return has_skipped_line
end

def bytesize
@buffer.bytesize
end

def has_skipped_line?
@has_skipped_line
end
end

class IOHandler
Expand Down Expand Up @@ -1203,8 +1199,7 @@ def handle_notify
@fifo << data

n_lines_before_read = @lines.size
@fifo.read_lines(@lines)
has_skipped_line = @fifo.has_skipped_line?
has_skipped_line = @fifo.read_lines(@lines) || has_skipped_line
group_watcher&.update_lines_read(@path, @lines.size - n_lines_before_read)

group_watcher_limit = group_watcher&.limit_lines_reached?(@path)
Expand All @@ -1227,11 +1222,9 @@ def handle_notify
end
end

if @lines.empty? && has_skipped_line
@watcher.pe.update_pos(io.pos - @fifo.bytesize)
end

unless @lines.empty?
if @lines.empty?
@watcher.pe.update_pos(io.pos - @fifo.bytesize) if has_skipped_line
else
if @receive_lines.call(@lines, @watcher)
@watcher.pe.update_pos(io.pos - @fifo.bytesize)
@lines.clear
Expand Down

0 comments on commit 05e7caf

Please sign in to comment.