-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
The Travis CI build failures seem unrelated to my change ... (UdpInputTest EADDRINUSE) |
Possible file rotation cases:
No problem.
Does anyone have any concern for this patch? |
If there are no problem, I will merge this patch today. |
@@ -593,13 +592,11 @@ def on_notify | |||
begin | |||
if @inode != inode || fsize < @fsize | |||
# rotated or truncated | |||
io = FileWrapper.open(@path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Errno::ENOENT occurs on FileWrapper.stat(@path)
, it seems Errno::ENOENT occurs again at here. Do not you need to handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So adding rescue nil
is better?
io = FileWrapper.open(@path) rescue nil
or
begin
io = FileWrapper.open(@path)
rescue Errno::ENOENT
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonots : good catch - thanks!
@repeatedly : I'll update the pull request with your suggestion
6beb2ad
to
b707ccc
Compare
@sonots Could you check again? |
@@ -593,13 +592,11 @@ def on_notify | |||
begin | |||
if @inode != inode || fsize < @fsize | |||
# rotated or truncated | |||
io = FileWrapper.open(@path) rescue nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you tell me when this io object will be closed? Or, not necessary to close? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should ignore only Errno::ENOENT as repeatedly wrote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sonots ,
Could you tell me when this io object will be closed?
The file descriptor is consumed here:
The first time through ... an io_handler is created here:
The file descriptor remains open until the next file rotation, removal, or fluentd shutdown. The logic to deal with some of these situations begins here:
Other cases are handled here:
For example, shutdown calls stop_watchers().
You should ignore only Errno::ENOENT as repeatedly wrote
Sorry, I thought @repeatedly was giving me a choice, and I picked the first option. I'll update the pull request using the second option. I'll also rebase against master.
David
f942a7d
to
2253719
Compare
LGTM |
in_tail: avoid unnecessary open()s
Thanks for the patch! |
in_tail: avoid unnecessary open()s
As discussed in https://groups.google.com/forum/#!topic/fluentd/BBRde4Lyl9E