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 Feb 12, 2016
2 parents a65118e + 2253719 commit 64c5d0c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ def initialize(path, log, &on_rotate)

def on_notify
begin
io = FileWrapper.open(@path)
stat = io.stat
stat = FileWrapper.stat(@path)
inode = stat.ino
fsize = stat.size
rescue Errno::ENOENT
Expand All @@ -599,13 +598,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 64c5d0c

Please sign in to comment.