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

Expose the "epoll_pwait2()" function #3868

Merged
merged 1 commit into from
Sep 1, 2024

Conversation

ChrysoliteAzalea
Copy link
Contributor

Hello everyone!

I propose exposing the epoll_pwait2() function. Epoll is a event polling/waiting feature in Linux. It is similar to poll(), but while poll() requires passing an event list on each call, epoll works by creating a file descriptor which can be filled with events on file descriptors and then be waited/polled multiple times. File descriptors and events can be added, modified and deleted during epoll fd lifetime, which is good for server applications -- they can watch the listening socket and register connection sockets for watching.

Polling and waiting happens by calling epoll_wait(), epoll_pwait() or epoll_pwait2(). The first system call implements only millisecond precision of wait timeout and does not provide a way to atomically alter the signal mask during wait. The second system call accepts a signal mask that will be the signal mask of the waiting thread until the system call returns. The third system call also allows setting the timeout with nanosecond precision. The libc crates exposes the first two but not the third one.

Related man-page

@rustbot
Copy link
Collaborator

rustbot commented Aug 24, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@ChrysoliteAzalea
Copy link
Contributor Author

ChrysoliteAzalea commented Aug 24, 2024

It looks like all failures here a related to musl. I've tried to use epoll_pwait2() with the upstream version of libc crate by exposing epoll_pwait2() through the extern block in my program. It works fine when built with glibc, but fails to build with musl. It looks like musl doesn't provide a wrapper function for epoll_pwait2().

P.S. I've looked up musl source code, and I haven't found a wrapper function for epoll_pwait2(). So I think I'll have to mark this PR as draft.

@ChrysoliteAzalea ChrysoliteAzalea marked this pull request as draft August 24, 2024 08:50
@ChrysoliteAzalea
Copy link
Contributor Author

Now all the checks are passing, the pull request is ready for review.

@ChrysoliteAzalea ChrysoliteAzalea marked this pull request as ready for review August 26, 2024 16:51
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you squash please?

@ChrysoliteAzalea
Copy link
Contributor Author

Thanks! Can you squash please?

OK, squashed.

@tgross35 tgross35 enabled auto-merge August 29, 2024 18:41
@tgross35
Copy link
Contributor

Thanks, looks like the CI failure was spurious so hopefully it passes this time.

The ```epoll_pwait2()``` function has been moved to linux/gnu
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Sep 1, 2024
@tgross35 tgross35 added this pull request to the merge queue Sep 1, 2024
Merged via the queue into rust-lang:main with commit cdf6896 Sep 1, 2024
41 checks passed
@ChrysoliteAzalea
Copy link
Contributor Author

Thank you!

@ChrysoliteAzalea
Copy link
Contributor Author

@tgross35
I wonder, since it's not a breaking change, can it be included in libc-0.2?

@tgross35
Copy link
Contributor

tgross35 commented Sep 1, 2024

It has the stable-nominated label already

@ChrysoliteAzalea
Copy link
Contributor Author

It has the stable-nominated label already

Oh, I see (I've looked at the labels now), thank you!

tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 5, 2024
The ```epoll_pwait2()``` function has been moved to linux/gnu

(backport <rust-lang#3868>)
(cherry picked from commit f3756b9)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 6, 2024
The ```epoll_pwait2()``` function has been moved to linux/gnu

(backport <rust-lang#3868>)
(cherry picked from commit f3756b9)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants