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

Simplify unix implementation #54

Merged
merged 3 commits into from
Oct 25, 2023
Merged

Simplify unix implementation #54

merged 3 commits into from
Oct 25, 2023

Conversation

NobodyXu
Copy link
Member

@NobodyXu NobodyXu commented Oct 25, 2023

  • Remove second param of set_nonblocking since it is always set to true
  • Remove is_pipe_without_access_mode_check, change is_pipe to only take one parameter and add fn get_access_mode for checking access mode separately.
  • Use ManuallyDrop::new(File::from_raw_fd(..)) to construct a File with no Drop so that we can call its metadata() and its try_clone() fn without having to implement them ourselves using unsafe code in dup*.
  • Fixed checking access mode of pipe fds: O_RDWR should also be accepted.

 - Remove second param of `set_nonblocking` since it is always set to
   `true`
 - Remove `is_pipe_without_access_mode_check`, change `is_pipe` to only
   take one parameter and add fn `get_access_mode` for checking access
   mode separately.
 - Use `ManuallyDrop::new(File::from_raw_fd(..))` to construct a `File`
   with no `Drop` so that we can call its `metadata()` and its
   `try_clone()` fn without having to implement them ourselves using
   `unsafe` code in `dup*`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu NobodyXu requested a review from passcod October 25, 2023 12:31
Copy link
Member

@passcod passcod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@NobodyXu NobodyXu merged commit 504f558 into main Oct 25, 2023
44 checks passed
@NobodyXu NobodyXu deleted the refactor branch October 25, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants