-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add pid to tokio::net::unix::UCred #2633
Conversation
This is a breaking change: use tokio::net::unix::UCred;
fn main() {
let a = UCred {
uid: 10,
gid: 10,
};
} |
Should it be behind a feature flag? How should that be named? |
A feature flag does not solve the issue. If some code compiles without a certain feature flag, it should also compile with that feature flag enabled. This is because when compiling code using Tokio, every feature required by any dependency is enabled for every dependency, and adding one dependency should not break other dependencies. This change will have to wait for v0.3 of Tokio. |
I will close the PR for now and come back to this once we prepare to release v0.3. |
We are working on v0.3 now. Can you submit a commit that merges in the master branch to your branch? |
rebased it onto master |
Hi. We made a change to this struct such that changes like this are not breaking changes in the future in #2936. Can you rebase again? Sorry about that. |
It's a bit awkward that we can't get it under MacOS. What would be missing to change that? Perhaps it's better to not provide the function on mac and not use an |
For me it's a mac. So I don't know enough about macos api, if it is possible |
Will disable it for now under MacOS. I think since 4.2BSD MacOS also supports getsockopt. But I'm not sure, and don't have anything to test it on. |
eb86bb4
to
936333b
Compare
As far as I can understand the docs and the source of darwin, it's not possible for us to get the PID of the peer process. |
Found another option, will try to get something working for darwin |
It breaks, while saying bad address. Not yet sure why |
Let me know if you figure out that its not possible on MacOS. |
Got it to work on my local MacOS hackintosh. |
I don't think this is a good idea, as users must specify complex cfgs ( |
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.
Please change the return type to Option
or use #[cfg_attr(docsrs, doc(cfg(any(target_os = ...))))]
on pid
function to improve docs.
I was hoping we could make it work everywhere and get rid of both the option and cfg. |
I didn't find this LOCAL_PEEREPID on another bsd. So no luck there |
That is most preferable if that is possible, but I don't think we need to block this PR until it becomes work everywhere. Also, if it becomes work everywhere in the future, we can add a document that says "This function always returns |
Fair enough. We can return an |
So readding the Option<pid_t> I removed before? |
Yes. |
Added it, with a small comment saying, where it is implemented |
* master: tracing: replace future names with spawn locations in task spans (tokio-rs#3074) util: add back public poll_read_buf() function (tokio-rs#3079) net: add pid to tokio::net::unix::UCred (tokio-rs#2633) chore: prepare tokio-util v0.5.0 release (tokio-rs#3078)
Motivation
Fixed: #2632
Solution
Provided pid as Optionlibc::pid_t so solaris and macos does not break.