Skip to content

Commit

Permalink
Merge pull request #788 from dwoo4dwoo/reduce_tail_opens
Browse files Browse the repository at this point in the history
in_tail: avoid unnecessary open()s
  • Loading branch information
repeatedly committed Mar 2, 2016
1 parent 8484c77 commit 212f4f8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,7 @@ def initialize(path, log, &on_rotate)

def on_notify
begin
io = File.open(@path)
stat = io.stat
stat = FileWrapper.stat(@path)
inode = stat.ino
fsize = stat.size
rescue Errno::ENOENT
Expand All @@ -593,14 +592,14 @@ def on_notify
begin
if @inode != inode || fsize < @fsize
# rotated or truncated
begin
io = FileWrapper.open(@path)
rescue Errno::ENOENT
end
@on_rotate.call(io)
io = nil
end

@inode = inode
@fsize = fsize
ensure
io.close if io
end

rescue
Expand Down

0 comments on commit 212f4f8

Please sign in to comment.