-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Do not block when handling dir containing a named pipe #83
base: master
Are you sure you want to change the base?
Conversation
Thank you for your PR! Would you also be able to add a test that checks for this? |
@XAMPPRocky I have reused the existing tests for this purpose, you can see the test setup in |
The last case would always return None since we already checked whether this is a directory. In case we were handling a file and no error (with the exception of is_eloop) occurred, set the file handle to None. For clarity, the file handle variable has been renamed to child_directory.
let child_directory = match child_result { | ||
// If we get EISDIR, we open it as a directory | ||
Err(e) if e.raw_os_error() == Some(libc::EISDIR) => { | ||
Some(opts.open_dir_at(dirfd, name)?) |
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.
This approach is doubling the number of syscalls - we're opening as a file then reopening again as a directory.
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.
... is it open_dir_at that is blocking?
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.
Yes, open_dir_at
always passes the O_RDONLY
flag, which blocks in the case of a named pipe (until it is opened for writing). open_at
gets the correct flags, but throws EISDIR
in case of a directory, which is why there is a second syscall for opening directories specifically.
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 will need to look at this somewhat more closely; if we can avoid the extra syscall that would be much better - this change would double the number of opens occuring.
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.
That sounds good, thank you for looking into it! Apologies for slow replies, I am currently on vacation for another 10 days, I will try and check this thread when I can 👍
This PR aims to address the issue described in Issue #82 .