-
Notifications
You must be signed in to change notification settings - Fork 286
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
programs: ProgramFd
is owned
#744
Conversation
Hey @alessandrod, this pull request changes the Aya Public API and requires your review. |
bb6c27b
to
4350519
Compare
✅ Deploy Preview for aya-rs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
4350519
to
277ee18
Compare
@tamird, this pull request is now in conflict and requires a rebase. |
277ee18
to
5748193
Compare
@tamird, this pull request is now in conflict and requires a rebase. |
5748193
to
8717bf1
Compare
35d85e5
to
db61441
Compare
db61441
to
5def006
Compare
ProgramFd
is borrowed from the programProgramFd
is owned
5def006
to
ffb2e9c
Compare
69d2afc
to
edd307c
Compare
@@ -174,7 +176,9 @@ impl Xdp { | |||
/// | |||
/// Ownership of the link will transfer to this program. | |||
pub fn attach_to_link(&mut self, link: XdpLink) -> Result<XdpLinkId, ProgramError> { | |||
let prog_fd = self.data.fd_or_err()?; | |||
let prog_fd = self.fd()?; |
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.
Here and everywhere else, why not do:
let prog_fd = self.fd()?.as_fd().as_raw_fd();
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.
Just personal preference - I prefer to avoid ?
in the middle of an expression. This will also make the diff cleaner when we get around to removing the need for as_raw_fd
; it'll be a pure deletion.
@tamird, this pull request is now in conflict and requires a rebase. |
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.
See nit, otherwise looks good
edd307c
to
e3dccba
Compare
Will merge after @dave-tucker has a chance to approve. |
e3dccba
to
e6afab9
Compare
`ProgramData::fd` is now a `ProgramFd`. This means that `ProgramData` now closes the file descriptor on drop. In the future we might consider making `ProgramFd` hold a `BorrowedFd` but this requires API design work due to overlapping borrows. Since `ProgramFd` is no longer `Copy`, update methods to take it by reference to allow callers to use it multiple times as they are accustomed to doing. `ProgramFd` is now returned by reference and implements `try_clone` to allow callers to avoid file descriptor cloning when desired. This is an API breaking change. Updates #612.
e6afab9
to
504fd1d
Compare
ProgramData::fd
is now also owned. This means thatProgramData
nowcloses the file descriptor on drop. In the future we might consider
making
ProgramFd
hold aBorrowedFd
but this requires API design workdue to overlapping borrows.
Since
ProgramFd
is no longerCopy
, update methods to take it byreference to allow callers to use it multiple times as they are
accustomed to doing.
This is an API breaking change.
Updates #612.