-
Notifications
You must be signed in to change notification settings - Fork 666
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
unistd: make getpeereid take AsFd rather than a raw FD #2137
unistd: make getpeereid take AsFd rather than a raw FD #2137
Conversation
`AsFd` returns a `BorrowedFd` that is correct by construction, meaning that this API rejects more error states at the type level (such as passing in `fd = -1`).
src/sys/socket/sockopt.rs
Outdated
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.
NB: Unrelated formatting changes in this file (made automatically). Happy to revert if you'd prefer to leave them out.
Ref #1750 |
BTW, the module |
It looks like there are some unresolved design questions in that PR's discussion, so I don't want to make this changeset harder to merge by adding those in. Does that seem reasonable? |
Sorry for being unclear, I was suggesting finishing the part that is missing from that PR (i.e., the following functions):
It should be okay to simply replace the |
Oh, gotcha! Yeah, I can definitely do that; sorry for the confusion on my part! |
Done -- all 5 of those APIs now take an |
Gentle ping on this, now that #2132 is semi-resolved 🙂 |
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.
I noticed that the
sockopt
APIs now takeAsFd
, so I figured this API should be made to do the same 🙂AsFd
returns aBorrowedFd
that is correct by construction, meaning that this API rejects more error states at the type level (such as passing infd = -1
). As such, I've removed thetest_getpeereid_invalid_fd
testcase, since its error state is no longer reachable from Rust users of this API.