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

inotify: Add AsFd to allow using with epoll (issue #1998) #1999

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

VorpalBlade
Copy link
Contributor

@VorpalBlade VorpalBlade commented Feb 8, 2023

This resolves issue #1998 and allows Inotify to be used by Epoll by adding AsFd.

I'm not entirely sure about the unit test. Maybe it would be possible to do a more comperhensive check by contructing inotify using from_raw_fd and checking that I get the same value back. However, that would basically mean duplicating Inotify::new and that feels a bit pointless.

Another option would be to create an integration test to combine Inotify and Epoll.

Fixes #1998

@VorpalBlade
Copy link
Contributor Author

Huh I don't understand the CI build failures. It works for me on stable rust (1.67.0). Yet it seems to be running on a much older version since it complains about AsFd not being a thing (supported since 1.63.0, which is the version that adds OwnedFd too, which was already used in that file).

@VorpalBlade
Copy link
Contributor Author

I did a change (where AsFd/BorrowedFd are imported from), but I do not understand why it was needed, as it builds without that change on my system. I would appreciate some explanation on this!

It also seems I get other errors building on CI than locally as well. I'm really confused by this. How do I build locally the same was as on CI?

@asomers
Copy link
Member

asomers commented Feb 13, 2023

I don't remember the exact version numbers, but one version of Rust stabilized the AsFd trait, and then a later version moved it to a different module within the standard library. That's why the first version of your PR failed. You must've been using a new Rust toolchain locally.

This PR looks good, but you don't need to bother with a test that short. If a one-line function can't be tested without essentially just restating what that function does, then the test adds no value.

@VorpalBlade
Copy link
Contributor Author

I don't remember the exact version numbers, but one version of Rust stabilized the AsFd trait, and then a later version moved it to a different module within the standard library. That's why the first version of your PR failed. You must've been using a new Rust toolchain locally.

Ah, that explains it. A bit of a footgun though in my opinion!

This PR looks good, but you don't need to bother with a test that short. If a one-line function can't be tested without essentially just restating what that function does, then the test adds no value.

I have removed the test now and squashed the changes into a single commit. Should be ready to merge!

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

LGTM.

bors r+

@bors bors bot merged commit 7b0cd34 into nix-rust:master Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combing Epoll and Inotify?
2 participants