-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
util: fix race condition in WaitForFile #3162
util: fix race condition in WaitForFile #3162
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Is this for slirp4netns API socket? |
IIRC, the ready-fd is written by the slirp4netns |
LGTM |
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.
I think we can simplify the code with using case <- time.After(...)
in line 129. Then we could delete lines 108-122 entirely.
yes good point. I'll change 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.
LGTM assuming happy tests
/hold |
I feel this is a bug. I opened rootless-containers/slirp4netns#90 |
82f9540
to
9aba820
Compare
/hold cancel Pushed a new version that simplifies it even further and doesn't use any go routine |
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.
LGTM, thanks @giuseppe
// also useful when using inotify as if for any reasons we missed | ||
// a notification, we won't hang the process. | ||
_, err := os.Stat(path) | ||
if err == 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.
Should we be checking if os.IsNotExist(err) and blowing up if the err is something else?
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.
I had moved the existing code, but yes that is better. I've pushed a new version where it checks the error type.
9aba820
to
a6cc93c
Compare
LGTM, |
Tests are very angry |
Looks like exec broke |
541f7f7
to
390f29c
Compare
enable polling also when using inotify. It is generally useful to have it as under high load inotify can lose notifications. It also solves a race condition where the file is created while the watcher is configured and it'd wait until the timeout and fail. Closes: containers#2942 Signed-off-by: Giuseppe Scrivano <[email protected]>
let the writer of the channel close it. Signed-off-by: Giuseppe Scrivano <[email protected]>
390f29c
to
f86bb56
Compare
@mheon tests are passing now |
/lgtm |
enable polling also when using inotify. It is generally useful to
have it as under high load inotify can lose notifications. It also
solves a race condition where the file is created while the watcher
is configured and it'd wait until the timeout and fail.
Closes: #2942
Signed-off-by: Giuseppe Scrivano [email protected]