Skip to content

Commit cd4db36

Browse files
committed
Rename with_retrying to retry_on_intr.
This makes it more explicit what it's doing.
1 parent e9b3be4 commit cd4db36

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/imp/libc/io/errno.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ impl Errno {
271271
/// `EINTR`
272272
///
273273
/// For a convenient way to retry system calls that exit with `INTR`, use
274-
/// [`with_retrying`].
274+
/// [`retry_on_intr`].
275275
///
276-
/// [`with_retrying`]: crate::io::with_retrying
276+
/// [`retry_on_intr`]: crate::io::retry_on_intr
277277
pub const INTR: Self = Self(c::EINTR);
278278
/// `EINVAL`
279279
pub const INVAL: Self = Self(c::EINVAL);

src/imp/linux_raw/io/errno.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ impl Errno {
311311
/// `EINTR`.
312312
///
313313
/// For a convenient way to retry system calls that exit with `INTR`, use
314-
/// [`with_retrying`].
314+
/// [`retry_on_intr`].
315315
///
316-
/// [`with_retrying`]: io::with_retrying
316+
/// [`retry_on_intr`]: io::retry_on_intr
317317
pub const INTR: Self = Self::from_errno(errno::EINTR);
318318
/// `EINVAL`
319319
pub const INVAL: Self = Self::from_errno(errno::EINVAL);

src/io/errno.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl From<Errno> for std::io::Error {
7575

7676
/// Call `f` until it either succeeds or fails other than [`Errno::INTR`].
7777
#[inline]
78-
pub fn with_retrying<T, F: FnMut() -> Result<T>>(mut f: F) -> Result<T> {
78+
pub fn retry_on_intr<T, F: FnMut() -> Result<T>>(mut f: F) -> Result<T> {
7979
loop {
8080
match f() {
8181
Err(Errno::INTR) => (),

src/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use crate::imp::io::epoll;
3030
pub use close::close;
3131
#[cfg(not(any(windows, target_os = "wasi")))]
3232
pub use dup::{dup, dup2, dup3, DupFlags};
33-
pub use errno::{with_retrying, Errno, Result};
33+
pub use errno::{retry_on_intr, Errno, Result};
3434
#[cfg(any(target_os = "android", target_os = "linux"))]
3535
pub use eventfd::{eventfd, EventfdFlags};
3636
#[cfg(any(target_os = "ios", target_os = "macos"))]

tests/io/poll.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustix::fd::{AsFd, AsRawFd, FromRawFd, IntoRawFd, OwnedFd};
22
#[cfg(not(windows))]
3-
use rustix::io::{poll, with_retrying};
3+
use rustix::io::{poll, retry_on_intr};
44
use rustix::io::{PollFd, PollFlags};
55

66
#[cfg(not(windows))]
@@ -14,16 +14,16 @@ fn test_poll() {
1414
assert_eq!(poll_fds[0].as_fd().as_raw_fd(), reader.as_fd().as_raw_fd());
1515

1616
// `poll` should say there's nothing ready to be read from the pipe.
17-
let num = with_retrying(|| poll(&mut poll_fds, 0)).unwrap();
17+
let num = retry_on_intr(|| poll(&mut poll_fds, 0)).unwrap();
1818
assert_eq!(num, 0);
1919
assert!(poll_fds[0].revents().is_empty());
2020
assert_eq!(poll_fds[0].as_fd().as_raw_fd(), reader.as_fd().as_raw_fd());
2121

2222
// Write a byte to the pipe.
23-
assert_eq!(with_retrying(|| write(&writer, b"a")).unwrap(), 1);
23+
assert_eq!(retry_on_intr(|| write(&writer, b"a")).unwrap(), 1);
2424

2525
// `poll` should now say there's data to be read.
26-
let num = with_retrying(|| poll(&mut poll_fds, -1)).unwrap();
26+
let num = retry_on_intr(|| poll(&mut poll_fds, -1)).unwrap();
2727
assert_eq!(num, 1);
2828
assert_eq!(poll_fds[0].revents(), PollFlags::IN);
2929
assert_eq!(poll_fds[0].as_fd().as_raw_fd(), reader.as_fd().as_raw_fd());
@@ -35,12 +35,12 @@ fn test_poll() {
3535

3636
// Read the byte from the pipe.
3737
let mut buf = [b'\0'];
38-
assert_eq!(with_retrying(|| read(&reader, &mut buf)).unwrap(), 1);
38+
assert_eq!(retry_on_intr(|| read(&reader, &mut buf)).unwrap(), 1);
3939
assert_eq!(buf[0], b'a');
4040
assert_eq!(poll_fds[0].as_fd().as_raw_fd(), reader.as_fd().as_raw_fd());
4141

4242
// Poll should now say there's no more data to be read.
43-
let num = with_retrying(|| poll(&mut poll_fds, 0)).unwrap();
43+
let num = retry_on_intr(|| poll(&mut poll_fds, 0)).unwrap();
4444
assert_eq!(num, 0);
4545
assert!(poll_fds[0].revents().is_empty());
4646
assert_eq!(poll_fds[0].as_fd().as_raw_fd(), reader.as_fd().as_raw_fd());

0 commit comments

Comments
 (0)