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

Add pselect syscall #894

Merged
merged 1 commit into from
Apr 28, 2018
Merged

Add pselect syscall #894

merged 1 commit into from
Apr 28, 2018

Conversation

antifuchs
Copy link
Contributor

I saw that #276 was closed, and now I need pselect, so here it is! I copied the function body from @abbradar's work, updated the type signatures, added two tests and added a doc comment.

Hope this works!

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.

Looks pretty good. In addition to my inline comments, could you also please add an entry to the CHANGELOG?

/// * `nfds`: The highest file descriptor set in any of the passed `FdSet`s, plus 1. If `None`, this
/// is calculated automatically by calling [`FdSet::highest`] on all descriptor sets and adding 1
/// to the maximum of that.
/// * `readfds`: File descriptors to check for being ready to read.
Copy link
Member

Choose a reason for hiding this comment

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

How about s/being ready to read/read readiness here and on the next two lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent point. Fixed.

@@ -227,6 +300,29 @@ mod tests {
assert!(!fd_set.contains(r2));
}

#[test]
#[cfg_attr(any(target_arch = "powerpc", target_arch = "mips"), ignore)]
Copy link
Member

Choose a reason for hiding this comment

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

If you're going to ignore the test on those two arches, you should explain why in a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! I forgot to drop that line when I cargo-culted this test. Thanks for spotting it!

None,
None,
&timeout,
&sigmask).unwrap());
Copy link
Member

Choose a reason for hiding this comment

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

Altering the signal mask has side effects which may interfere with other concurrent tests. Nix has a way of dealing with that: you should this test into test/sys/test_select.rs and then add this line to the top:

let _mtx = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");

Since the other test does not modify the sigmask, you don't need the mutex. It's up to you whether or not to move it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I'll move both.

Copy link
Contributor Author

@antifuchs antifuchs left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I just pushed a new change with the requested changes.

/// * `nfds`: The highest file descriptor set in any of the passed `FdSet`s, plus 1. If `None`, this
/// is calculated automatically by calling [`FdSet::highest`] on all descriptor sets and adding 1
/// to the maximum of that.
/// * `readfds`: File descriptors to check for being ready to read.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent point. Fixed.

@@ -227,6 +300,29 @@ mod tests {
assert!(!fd_set.contains(r2));
}

#[test]
#[cfg_attr(any(target_arch = "powerpc", target_arch = "mips"), ignore)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! I forgot to drop that line when I cargo-culted this test. Thanks for spotting it!

None,
None,
&timeout,
&sigmask).unwrap());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I'll move both.


#[test]
pub fn test_pselect_nfds2() {
let _mtx = ::SIGNAL_MTX
Copy link
Member

Choose a reason for hiding this comment

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

You put _mtx in the wrong test; only test_pselect modifies the sigmask.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦🏻‍♂️ oh no

This is a straight port of @abbradar's work in nix-rust#276, with
two (somewhat weak) tests and a bit of documentation.
@antifuchs
Copy link
Contributor Author

Updated once again, hahaha, I should probably go to bed (:

@asomers
Copy link
Member

asomers commented Apr 28, 2018

thanks for your contribution!

bors r+

bors bot added a commit that referenced this pull request Apr 28, 2018
894: Add pselect syscall r=asomers a=antifuchs

I saw that #276 was closed, and now I need `pselect`, so here it is! I copied the function body from @abbradar's work, updated the type signatures, added two tests and added a doc comment.

Hope this works!

Co-authored-by: Andreas Fuchs <[email protected]>
@bors
Copy link
Contributor

bors bot commented Apr 28, 2018

@bors bors bot merged commit 492903b into nix-rust:master Apr 28, 2018
@antifuchs antifuchs deleted the pselect branch June 10, 2018 16:46
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.

2 participants