-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix an inconsistency in Linux version of TcpListener::accept #67028
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Kimundi (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
That implementation is racy with concurrent changes to the blocking-ness of the socket. It also doubles the number of system calls per accept call. We generally try to expose the system primitive without a lot of extra stuff on top. " |
Agree reg race, I found unfortunate that It also doesn’t allow to introduce any state to avoid extra syscall, however that design may be error prone. I think for non-blocking io in the majority of the cases we would have the same amount of syscalls, while doubling it for blocking io. I’m not sure about the last point. I think about complexity from api user point of view. How many people needs to know details of impl and how hard to figure it out? At the same time there are millions of users of this method and for them we have a complex story - “what you get depends on listener state unless you are on linux then you always get blocking stream”. Also there is no single hint that this call is platform-dependent. |
r? @KodrAus |
☔ The latest upstream changes (presumably #67449) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage: @hashmap can you please address the merge conflicts? |
Pinging again from triage: @hashmap can you post the status of this pr? Thanks. |
If TcpListener is in non-blocking mode then accepted streams inherit this property on all platforms except Linux, where accept4 is used instead of accept. This fix checks if a listener is in non-blocking mode and pass the corresponding flag to accept4. Fixes rust-lang#67027
cf6edc9
to
ab611df
Compare
Sorry, I've finally rebased this pr. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I'm still not convinced that the standard library should be trying to fudge this. @rfcbot fcp close |
Team member @sfackler has proposed to close this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Adding documentation to explain this better would probably makes sense, if the decision is to not change behavior. |
The final comment period, with a disposition to close, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
If TcpListener is in non-blocking mode then accepted streams inherit
this property on all platforms except Linux, where accept4 is used
instead of accept.
This fix checks if a listener is in non-blocking mode and pass the
corresponding flag to accept4.
Fixes #67027