Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_tail: avoid unnecessary open()s #788

Merged
merged 1 commit into from
Feb 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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