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

Replacing RawFd with OwnedFd for compatibility with nix crate #26

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

eesekaj
Copy link

@eesekaj eesekaj commented Oct 28, 2024

Hello,

Please find attached a pull request where the following changes were made:

  1. RawFd was replaced in favor of OwnedFd. The nix crate is no longer accepts the RawFd as argument and requires the BorrowedFd to be passed as argument.
    OwnedFd is:

An owned file descriptor.

This closes the file descriptor on drop. It is guaranteed that nobody else will close the file descriptor.

This uses repr(transparent) and has the representation of a host file descriptor, so it can be used in FFI in places where a file descriptor is passed as a consumed argument or returned as an owned value, and it never has the value -1.

You can use AsFd::as_fd to obtain a BorrowedFd.

  1. Updated the crates versions. This is not necessary, but this crate forces to download additional dependencies.
  2. Added a function "send_flags" in "UnixSeqpacketConn". + impl AsFd and commented out the impl Drop (as OwnedFd should close the socket).
  3. Removed unused import.

Tested with default features on GNU/Linux.

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.

1 participant