id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/io_async_fd.rs:7 | #[derive(Debug)]
struct ArcFd<T>(Arc<T>);
impl<T: AsRawFd> AsRawFd for ArcFd<T> {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}
#[tokio::test]
async fn drop_closes() {
let (a, mut b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
assert_eq!(
ErrorKind::WouldBlock,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:8 | assert_eq!(
ErrorKind::WouldBlock,
b.read(&mut [0]).err().unwrap().kind()
);
std::mem::drop(arc_fd); // suppress unnecessary clone clippy warning
}
#[tokio::test]
async fn reregister() {
let (a, _b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
let a = afd_a.into_inner();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:9 | tokio::pin!(readable);
tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
// Write something down b again and make sure we're reawoken
b.write_all(b"0").unwrap();
let _ = readable.await.unwrap();
}
#[tokio::test]
async fn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | };
tasks.push(tokio::spawn(f));
}
let mut all_tasks = futures::future::try_join_all(tasks);
tokio::select! {
r = std::pin::Pin::new(&mut all_tasks) => {
r.unwrap(); // propagate panic
panic!("Tasks exited unexpectedly")
},
_ = barrier.wait() => {}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:11 | let read_fut = tokio::spawn(async move {
// Move waker onto this task first
assert_pending!(poll!(std::future::poll_fn(|cx| afd_a_2
.as_ref()
.poll_read_ready(cx))));
barrier_clone.wait().await;
let _ = std::future::poll_fn(|cx| afd_a_2.as_ref().poll_read_ready(c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:12 | // Our original waker should _not_ be awoken (poll_read_ready retains only the last context)
assert!(!waker.awoken());
// The writable side should not be awoken
tokio::select! {
_ = &mut write_fut => unreachable!(),
_ = tokio::time::sleep(Duration::from_millis(5)) => {}
}
// Make i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:13 | AsyncFd::new(a).unwrap()
};
let readable = assert_pending(afd_a.readable());
std::mem::drop(rt);
// The future was initialized **before** dropping the rt
assert_err!(futures::executor::block_on(readable));
// The future is initialized **after** dropping the rt.
assert_err!(futures::execu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:14 | let _ = std::thread::spawn(move || std::mem::drop(rt));
// This may or may not return an error (but will be awoken)
let _ = futures::executor::block_on(afd_a.readable());
// However retrying will always return an error
assert_err!(futures::executor::block_on(afd_a.readable()));
}
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:15 | #[test]
fn driver_shutdown_wakes_poll() {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
std::mem::drop(rt);
assert_err!(futures::executor::block_on(poll_readable(&afd_a)));
assert_err!(futures::executor::block... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:16 | let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
while afd_a.get_ref().write(&[0; 512]).is_ok() {} // make not writable
let _ = std::thread::spawn(move || std::mem::drop(rt));
// The poll variants will alway... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:17 | fn send_oob_data<S: AsRawFd>(stream: &S, data: &[u8]) -> io::Result<usize> {
unsafe {
let res = libc::send(
stream.as_raw_fd(),
data.as_ptr().cast(),
data.len(),
libc::MSG_OOB,
);
if res == -1 {
Err(io::Error::last_os_error())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:18 | #[tokio::test]
#[cfg_attr(miri, ignore)]
async fn clear_ready_matching_clears_ready_mut() {
use tokio::io::{Interest, Ready};
let (a, mut b) = socketpair();
let mut afd_a = AsyncFd::new(a).unwrap();
b.write_all(b"0").unwrap();
let mut guard = afd_a
.ready_mut(Interest::READABLE | Interest... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:19 | configure_timestamping_socket(&socket).unwrap();
socket.connect(address_b).unwrap();
let fd = AsyncFd::new(socket).unwrap();
tokio::select! {
_ = fd.ready(Interest::ERROR) => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
let buf = b"hello there";
fd.get_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:20 | #[tokio::test]
#[cfg(target_os = "linux")]
#[cfg_attr(miri, ignore)]
async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
let socket_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let socket = std::net::UdpSocket::bind(socket_add... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | // Prepare the message data
let message = "Hello, Socket!";
// Prepare the message structure for sendmsg
let mut iov = libc::iovec {
iov_base: message.as_ptr() as *mut libc::c_void,
iov_len: message.len(),
};
// Prepare the destination address for the se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 801 | 859 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:22 | #[tokio::test]
async fn try_new() {
let original = Arc::new(InvalidSource);
let error = AsyncFd::try_new(original.clone()).unwrap_err();
let (returned, _cause) = error.into_parts();
assert!(Arc::ptr_eq(&original, &returned));
}
#[tokio::test]
async fn try_with_interest() {
let original = Arc::new... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_async_fd.rs | 841 | 859 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:16 | let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
while afd_a.get_ref().write(&[0; 512]).is_ok() {} // make not writable
let _ = std::thread::spawn(move || std::mem::drop(rt));
// The poll variants will alway... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:17 | fn send_oob_data<S: AsRawFd>(stream: &S, data: &[u8]) -> io::Result<usize> {
unsafe {
let res = libc::send(
stream.as_raw_fd(),
data.as_ptr().cast(),
data.len(),
libc::MSG_OOB,
);
if res == -1 {
Err(io::Error::last_os_error())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:18 | async fn clear_ready_matching_clears_ready_mut() {
use tokio::io::{Interest, Ready};
let (a, mut b) = socketpair();
let mut afd_a = AsyncFd::new(a).unwrap();
b.write_all(b"0").unwrap();
let mut guard = afd_a
.ready_mut(Interest::READABLE | Interest::WRITABLE)
.await
.unwra... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:19 | let fd = AsyncFd::new(socket).unwrap();
tokio::select! {
_ = fd.ready(Interest::ERROR) => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
let buf = b"hello there";
fd.get_ref().send(buf).unwrap();
// the send timestamp should now be in the error queue
let g... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:20 | async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
let socket_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let socket = std::net::UdpSocket::bind(socket_addr).unwrap();
let socket_fd = socket.as_raw_fd();
// Enable I... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | // Prepare the message structure for sendmsg
let mut iov = libc::iovec {
iov_base: message.as_ptr() as *mut libc::c_void,
iov_len: message.len(),
};
// Prepare the destination address for the sendmsg call
let dest_sockaddr: *const libc::sockaddr = &dest_addr as *... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 801 | 855 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:22 | let error = AsyncFd::try_new(original.clone()).unwrap_err();
let (returned, _cause) = error.into_parts();
assert!(Arc::ptr_eq(&original, &returned));
}
#[tokio::test]
async fn try_with_interest() {
let original = Arc::new(InvalidSource);
let error = AsyncFd::try_with_interest(original.clone(), Intere... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/io_async_fd.rs | 841 | 855 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | };
tasks.push(tokio::spawn(f));
}
let mut all_tasks = futures::future::try_join_all(tasks);
tokio::select! {
r = std::pin::Pin::new(&mut all_tasks) => {
r.unwrap(); // propagate panic
panic!("Tasks exited unexpectedly")
},
_ = barrier.wait() => {}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 2d697fc92b012bf274e70d0f70bf7e4717a59f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2d697fc92b012bf274e70d0f70bf7e4717a59f31/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:11 | let read_fut = tokio::spawn(async move {
// Move waker onto this task first
assert_pending!(poll!(futures::future::poll_fn(|cx| afd_a_2
.as_ref()
.poll_read_ready(cx))));
barrier_clone.wait().await;
let _ = futures::future::poll_fn(|cx| afd_a_2.as_ref().poll_read... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 2d697fc92b012bf274e70d0f70bf7e4717a59f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2d697fc92b012bf274e70d0f70bf7e4717a59f31/tokio/tests/io_async_fd.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:13 | AsyncFd::new(a).unwrap()
};
let readable = assert_pending(afd_a.readable());
std::mem::drop(rt);
// The future was initialized **before** dropping the rt
assert_err!(futures::executor::block_on(readable));
// The future is initialized **after** dropping the rt.
assert_err!(futures::execu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 2d697fc92b012bf274e70d0f70bf7e4717a59f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2d697fc92b012bf274e70d0f70bf7e4717a59f31/tokio/tests/io_async_fd.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:14 | let _ = std::thread::spawn(move || std::mem::drop(rt));
// This may or may not return an error (but will be awoken)
let _ = futures::executor::block_on(afd_a.readable());
// However retrying will always return an error
assert_err!(futures::executor::block_on(afd_a.readable()));
}
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 2d697fc92b012bf274e70d0f70bf7e4717a59f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2d697fc92b012bf274e70d0f70bf7e4717a59f31/tokio/tests/io_async_fd.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:3 | impl Write for &FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
write(&self.fd, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl Write for FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:4 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
let (fd_a, fd_b) = socket::socketpair(
AddressFamily::Unix,
SockType::Stream,
None,
SockFlag::empty(),
)
.expect("socketpair");
let fds = (FileDescriptor { fd: fd_a }, FileDescriptor { fd: fd_b });
set... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:6 | tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
b.write_all(b"0").unwrap();
// We can observe the new readable event
afd_a.readable().await.unwrap().clear_ready();
}
#[tokio::test]
async fn reset_writable() {
let (a, b)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:7 | #[derive(Debug)]
struct ArcFd<T>(Arc<T>);
impl<T: AsRawFd> AsRawFd for ArcFd<T> {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}
#[tokio::test]
async fn drop_closes() {
let (a, mut b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
assert_eq!(
ErrorKind::WouldBlock,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:8 | assert_eq!(
ErrorKind::WouldBlock,
b.read(&mut [0]).err().unwrap().kind()
);
std::mem::drop(arc_fd); // suppress unnecessary clone clippy warning
}
#[tokio::test]
async fn reregister() {
let (a, _b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
let a = afd_a.into_inner();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:9 | let readable = afd_a.readable();
tokio::pin!(readable);
tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
// Write something down b again and make sure we're reawoken
b.write_all(b"0").unwrap();
let _ = readable.await.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | std::mem::drop(afd_a);
};
tasks.push(tokio::spawn(f));
}
let mut all_tasks = futures::future::try_join_all(tasks);
tokio::select! {
r = std::pin::Pin::new(&mut all_tasks) => {
r.unwrap(); // propagate panic
panic!("Tasks exited unexpectedly")
},
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:11 | assert_pending!(poll!(futures::future::poll_fn(|cx| afd_a_2
.as_ref()
.poll_read_ready(cx))));
barrier_clone.wait().await;
let _ = futures::future::poll_fn(|cx| afd_a_2.as_ref().poll_read_ready(cx)).await;
});
let afd_a_2 = afd_a.clone();
let w_barrier = Arc::new(to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:12 | // The writable side should not be awoken
tokio::select! {
_ = &mut write_fut => unreachable!(),
_ = tokio::time::sleep(Duration::from_millis(5)) => {}
}
// Make it writable now
drain(afd_b.get_ref());
// now we should be writable (ie - the waker for poll_write should still be regi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:13 | let readable = assert_pending(afd_a.readable());
std::mem::drop(rt);
// The future was initialized **before** dropping the rt
assert_err!(futures::executor::block_on(readable));
// The future is initialized **after** dropping the rt.
assert_err!(futures::executor::block_on(afd_a.readable()));
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:14 | // This may or may not return an error (but will be awoken)
let _ = futures::executor::block_on(afd_a.readable());
// However retrying will always return an error
assert_err!(futures::executor::block_on(afd_a.readable()));
}
}
async fn poll_readable<T: AsRawFd>(fd: &AsyncFd<T>) -> std::io:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:15 | fn driver_shutdown_wakes_poll() {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
std::mem::drop(rt);
assert_err!(futures::executor::block_on(poll_readable(&afd_a)));
assert_err!(futures::executor::block_on(poll... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:16 | let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
while afd_a.get_ref().write(&[0; 512]).is_ok() {} // make not writable
let _ = std::thread::spawn(move || std::mem::drop(rt));
// The poll variants will always return an error in this case
assert_err!(futures::ex... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:17 | let res = libc::send(
stream.as_raw_fd(),
data.as_ptr().cast(),
data.len(),
libc::MSG_OOB,
);
if res == -1 {
Err(io::Error::last_os_error())
} else {
Ok(res as usize)
}
}
}
#[tokio::test]
async fn clear_ready_ma... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:18 | let (a, mut b) = socketpair();
let mut afd_a = AsyncFd::new(a).unwrap();
b.write_all(b"0").unwrap();
let mut guard = afd_a
.ready_mut(Interest::READABLE | Interest::WRITABLE)
.await
.unwrap();
assert_eq!(guard.ready(), Ready::READABLE | Ready::WRITABLE);
guard.clear_ready... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:19 | tokio::select! {
_ = fd.ready(Interest::ERROR) => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
let buf = b"hello there";
fd.get_ref().send(buf).unwrap();
// the send timestamp should now be in the error queue
let guard = fd.ready(Interest::ERROR).await.unwrap... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:20 | use tokio::io::{Interest, Ready};
let socket_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let socket = std::net::UdpSocket::bind(socket_addr).unwrap();
let socket_fd = socket.as_raw_fd();
// Enable IP_RECVERR option to receive error messages
// https://man7.org/linux/man-pages/man7/ip.7.html... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | iov_base: message.as_ptr() as *mut libc::c_void,
iov_len: message.len(),
};
// Prepare the destination address for the sendmsg call
let dest_sockaddr: *const libc::sockaddr = &dest_addr as *const _ as *const libc::sockaddr;
let dest_addrlen: libc::socklen_t = std::mem::size_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 801 | 853 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:22 | assert!(Arc::ptr_eq(&original, &returned));
}
#[tokio::test]
async fn try_with_interest() {
let original = Arc::new(InvalidSource);
let error = AsyncFd::try_with_interest(original.clone(), Interest::READABLE).unwrap_err();
let (returned, _cause) = error.into_parts();
assert!(Arc::ptr_eq(&original, &r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 17819062e27b48570dd7f510b8bf8cf7b0e52cf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17819062e27b48570dd7f510b8bf8cf7b0e52cf4/tokio/tests/io_async_fd.rs | 841 | 853 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:9 | let readable = afd_a.readable();
tokio::pin!(readable);
tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
// Write something down b again and make sure we're reawoken
b.write_all(b"0").unwrap();
let _ = readable.await.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/io_async_fd.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | std::mem::drop(afd_a);
};
tasks.push(tokio::spawn(f));
}
let mut all_tasks = futures::future::try_join_all(tasks);
tokio::select! {
r = std::pin::Pin::new(&mut all_tasks) => {
r.unwrap(); // propagate panic
panic!("Tasks exited unexpectedly")
},
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(unix, feature = "full"))]
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use std::time::Duration;
use std::{
future::Future,
io::{self, ErrorKind, Read, Write},
task::{Context, Waker},
};
use nix::u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:2 | fn new() -> Self {
let inner: Arc<TestWakerInner> = Default::default();
Self {
inner: inner.clone(),
waker: futures::task::waker(inner),
}
}
fn awoken(&self) -> bool {
self.inner.awoken.swap(false, Ordering::SeqCst)
}
fn context(&self) -> Contex... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:3 | impl Write for &FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
write(self.fd, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl Write for FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:4 | let flags = OFlag::from_bits_truncate(flags) | OFlag::O_NONBLOCK;
nix::fcntl::fcntl(fd, F_SETFL(flags)).expect("fcntl(F_SETFD)");
}
fn socketpair() -> (FileDescriptor, FileDescriptor) {
use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
let (fd_a, fd_b) = socket::socketpair(
Address... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:5 | }
}
#[tokio::test]
async fn initially_writable() {
let (a, b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
let afd_b = AsyncFd::new(b).unwrap();
afd_a.writable().await.unwrap().clear_ready();
afd_b.writable().await.unwrap().clear_ready();
tokio::select! {
biased;
_ =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:6 | .try_io(|_| afd_a.get_ref().read(&mut [0]))
.unwrap()
.unwrap();
// `a` is not readable, but the reactor still thinks it is
// (because we have not observed a not-ready error yet)
afd_a.readable().await.unwrap().retain_ready();
// Explicitly clear the ready state
guard.clear_ready(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:7 | let writable = afd_a.writable();
tokio::pin!(writable);
tokio::select! {
_ = writable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
// Read from the other side; we should become writable now.
drain(&b);
let _ = writable.await.unwrap();
}
#[de... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:8 | let afd_a = AsyncFd::new(a).unwrap();
let _a: FileDescriptor = afd_a.into_inner();
assert_eq!(
ErrorKind::WouldBlock,
b.read(&mut [0]).err().unwrap().kind()
);
// Drop closure behavior is delegated to the inner object
let (a, mut b) = socketpair();
let arc_fd = Arc::new(a);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:9 | afd_a.get_ref().read_exact(&mut [0]).unwrap();
// Should not clear the readable state
let _ = guard.try_io(|_| Ok(()));
// Still readable...
let _ = afd_a.readable().await.unwrap();
// Should clear the readable state
let _ = guard.try_io(|_| io::Result::<()>::Err(ErrorKind::WouldBlock.into())... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | barrier.wait().await;
futures::future::pending::<()>().await;
};
tokio::select! {
biased;
guard = afd_a.readable() => {
tokio::task::yield_now().await;
guard.unwrap().clear_ready()
},
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:11 | // Fill up the write side of A
while afd_a.get_ref().write(&[0; 512]).is_ok() {}
let waker = TestWaker::new();
assert_pending!(afd_a.as_ref().poll_read_ready(&mut waker.context()));
let afd_a_2 = afd_a.clone();
let r_barrier = Arc::new(tokio::sync::Barrier::new(2));
let barrier_clone = r_barr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:12 | tokio::select! {
_ = &mut readable => unreachable!(),
_ = tokio::task::yield_now() => {}
}
// Make A readable. We expect that 'readable' and 'read_fut' will both complete quickly
afd_b.get_ref().write_all(b"0").unwrap();
let _ = tokio::join!(readable, read_fut);
// Our original wa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:13 | .build()
.unwrap()
}
#[test]
fn driver_shutdown_wakes_currently_pending() {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
let readable = assert_pending(afd_a.readable());
std::mem::drop(rt);
// The f... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:14 | #[test]
fn driver_shutdown_wakes_pending_race() {
// TODO: make this a loom test
for _ in 0..100 {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
let _ = std::thread::spawn(move || st... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:15 | while afd_a.get_ref().write(&[0; 512]).is_ok() {} // make not writable
let readable = assert_pending(poll_readable(&afd_a));
let writable = assert_pending(poll_writable(&afd_a));
std::mem::drop(rt);
// Attempting to poll readiness when the rt is dropped is an error
assert_err!(futures::executor::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:16 | std::mem::drop(rt);
write_ready.clear_ready();
}
#[test]
fn driver_shutdown_wakes_poll_race() {
// TODO: make this a loom test
for _ in 0..100 {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:17 | let client = AsyncFd::with_interest(client, Interest::PRIORITY).unwrap();
let (stream, _) = listener.accept().unwrap();
// Sending out of band data should trigger priority event.
send_oob_data(&stream, b"hello").unwrap();
let _ = client.ready(Interest::PRIORITY).await.unwrap();
}
#[cfg(any(target_os... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:18 | assert_eq!(guard.ready(), Ready::READABLE | Ready::WRITABLE);
guard.clear_ready_matching(Ready::READABLE);
assert_eq!(guard.ready(), Ready::WRITABLE);
guard.clear_ready_matching(Ready::WRITABLE);
assert_eq!(guard.ready(), Ready::EMPTY);
}
#[tokio::test]
async fn clear_ready_matching_clears_ready_mut(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:19 | let address_a = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let address_b = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let socket = std::net::UdpSocket::bind(address_a).unwrap();
socket.set_nonblocking(true).unwrap();
// configure send timestamps
configure_timestamping_socket(&socket).unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:20 | };
if res == -1 {
Err(std::io::Error::last_os_error())
} else {
Ok(res)
}
}
#[tokio::test]
#[cfg(target_os = "linux")]
async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
let socket_addr = SocketAddr::from(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | let mut dest_addr =
unsafe { std::mem::MaybeUninit::<libc::sockaddr_in>::zeroed().assume_init() };
dest_addr.sin_family = libc::AF_INET as _;
// based on https://en.wikipedia.org/wiki/Ephemeral_port, we should pick a port number
// below 1024 to guarantee that other tests don't selec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:22 | impl AsRawFd for InvalidSource {
fn as_raw_fd(&self) -> RawFd {
-1
}
}
#[tokio::test]
async fn try_new() {
let original = Arc::new(InvalidSource);
let error = AsyncFd::try_new(original.clone()).unwrap_err();
let (returned, _cause) = error.into_parts();
assert!(Arc::ptr_eq(&original, &... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 3936ebdfe4f44eda5630a9b461bbbc9976e5542c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3936ebdfe4f44eda5630a9b461bbbc9976e5542c/tokio/tests/io_async_fd.rs | 841 | 866 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:4 | let flags = OFlag::from_bits_truncate(flags) | OFlag::O_NONBLOCK;
nix::fcntl::fcntl(fd, F_SETFL(flags)).expect("fcntl(F_SETFD)");
}
fn socketpair() -> (FileDescriptor, FileDescriptor) {
use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
let (fd_a, fd_b) = socket::socketpair(
Address... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | e37bd6385430620f850a644d58945ace541afb6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e37bd6385430620f850a644d58945ace541afb6e/tokio/tests/io_async_fd.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(unix, feature = "full"))]
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use std::time::Duration;
use std::{
future::Future,
io::{self, ErrorKind, Read, Write},
task::{Context, Waker},
};
use nix::u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:2 | let inner: Arc<TestWakerInner> = Default::default();
Self {
inner: inner.clone(),
waker: futures::task::waker(inner),
}
}
fn awoken(&self) -> bool {
self.inner.awoken.swap(false, Ordering::SeqCst)
}
fn context(&self) -> Context<'_> {
Context::fr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:3 | impl Write for &FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
write(self.fd, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl Write for FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:4 | nix::fcntl::fcntl(fd, F_SETFL(flags)).expect("fcntl(F_SETFD)");
}
fn socketpair() -> (FileDescriptor, FileDescriptor) {
use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
let (fd_a, fd_b) = socket::socketpair(
AddressFamily::Unix,
SockType::Stream,
None,
SockFlag:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:5 | }
#[tokio::test]
async fn initially_writable() {
let (a, b) = socketpair();
let afd_a = AsyncFd::new(a).unwrap();
let afd_b = AsyncFd::new(b).unwrap();
afd_a.writable().await.unwrap().clear_ready();
afd_b.writable().await.unwrap().clear_ready();
tokio::select! {
biased;
_ = t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:6 | .unwrap()
.unwrap();
// `a` is not readable, but the reactor still thinks it is
// (because we have not observed a not-ready error yet)
afd_a.readable().await.unwrap().retain_ready();
// Explicitly clear the ready state
guard.clear_ready();
let readable = afd_a.readable();
tokio::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:7 | tokio::pin!(writable);
tokio::select! {
_ = writable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
// Read from the other side; we should become writable now.
drain(&b);
let _ = writable.await.unwrap();
}
#[derive(Debug)]
struct ArcFd<T>(Arc<T>);... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:8 | let _a: FileDescriptor = afd_a.into_inner();
assert_eq!(
ErrorKind::WouldBlock,
b.read(&mut [0]).err().unwrap().kind()
);
// Drop closure behavior is delegated to the inner object
let (a, mut b) = socketpair();
let arc_fd = Arc::new(a);
let afd_a = AsyncFd::new(ArcFd(arc_fd.clo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | futures::future::pending::<()>().await;
};
tokio::select! {
biased;
guard = afd_a.readable() => {
tokio::task::yield_now().await;
guard.unwrap().clear_ready()
},
_ = notify_barrier => unreach... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:11 | while afd_a.get_ref().write(&[0; 512]).is_ok() {}
let waker = TestWaker::new();
assert_pending!(afd_a.as_ref().poll_read_ready(&mut waker.context()));
let afd_a_2 = afd_a.clone();
let r_barrier = Arc::new(tokio::sync::Barrier::new(2));
let barrier_clone = r_barrier.clone();
let read_fut = to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:13 | .unwrap()
}
#[test]
fn driver_shutdown_wakes_currently_pending() {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
let readable = assert_pending(afd_a.readable());
std::mem::drop(rt);
// The future was initial... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:14 | fn driver_shutdown_wakes_pending_race() {
// TODO: make this a loom test
for _ in 0..100 {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
let _ = std::thread::spawn(move || std::mem::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:15 | let readable = assert_pending(poll_readable(&afd_a));
let writable = assert_pending(poll_writable(&afd_a));
std::mem::drop(rt);
// Attempting to poll readiness when the rt is dropped is an error
assert_err!(futures::executor::block_on(readable));
assert_err!(futures::executor::block_on(writable));... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:16 | write_ready.clear_ready();
}
#[test]
fn driver_shutdown_wakes_poll_race() {
// TODO: make this a loom test
for _ in 0..100 {
let rt = rt();
let (a, _b) = socketpair();
let afd_a = {
let _enter = rt.enter();
AsyncFd::new(a).unwrap()
};
while afd_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:17 | let (stream, _) = listener.accept().unwrap();
// Sending out of band data should trigger priority event.
send_oob_data(&stream, b"hello").unwrap();
let _ = client.ready(Interest::PRIORITY).await.unwrap();
}
#[cfg(any(target_os = "linux", target_os = "android"))]
fn send_oob_data<S: AsRawFd>(stream: &S, d... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:18 | assert_eq!(guard.ready(), Ready::READABLE | Ready::WRITABLE);
guard.clear_ready_matching(Ready::READABLE);
assert_eq!(guard.ready(), Ready::WRITABLE);
guard.clear_ready_matching(Ready::WRITABLE);
assert_eq!(guard.ready(), Ready::EMPTY);
}
#[tokio::test]
async fn clear_ready_matching_clears_ready_mut(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:19 | let address_b = SocketAddr::from((Ipv4Addr::LOCALHOST, 0));
let socket = std::net::UdpSocket::bind(address_a).unwrap();
socket.set_nonblocking(true).unwrap();
// configure send timestamps
configure_timestamping_socket(&socket).unwrap();
socket.connect(address_b).unwrap();
let fd = AsyncFd::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:20 | if res == -1 {
Err(std::io::Error::last_os_error())
} else {
Ok(res)
}
}
#[tokio::test]
#[cfg(target_os = "linux")]
async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
let socket_addr = SocketAddr::from((Ipv4Add... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | unsafe { std::mem::MaybeUninit::<libc::sockaddr_in>::zeroed().assume_init() };
dest_addr.sin_family = libc::AF_INET as _;
// based on https://en.wikipedia.org/wiki/Ephemeral_port, we should pick a port number
// below 1024 to guarantee that other tests don't select this port by accident when the... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_async_fd.rs | 801 | 836 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:21 | unsafe { std::mem::MaybeUninit::<libc::sockaddr_in>::zeroed().assume_init() };
dest_addr.sin_family = libc::AF_INET as _;
// based on https://en.wikipedia.org/wiki/Ephemeral_port, we should pick a port number
// below 1024 to guarantee that other tests don't select this port by accident when the... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | a0a58d7edd9554c56c235797f32f0200335bdc3e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0a58d7edd9554c56c235797f32f0200335bdc3e/tokio/tests/io_async_fd.rs | 801 | 836 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(unix, feature = "full"))]
use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use std::time::Duration;
use std::{
future::Future,
io::{self, ErrorKind, Read, Write},
task::{Context, Waker},
};
use nix::unistd::{clo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:3 | impl Write for &FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
write(self.fd, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl Write for FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:4 | nix::fcntl::fcntl(fd, F_SETFL(flags)).expect("fcntl(F_SETFD)");
}
fn socketpair() -> (FileDescriptor, FileDescriptor) {
use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
let (fd_a, fd_b) = socket::socketpair(
AddressFamily::Unix,
SockType::Stream,
None,
SockFlag:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:5 | let afd_b = AsyncFd::new(b).unwrap();
afd_a.writable().await.unwrap().clear_ready();
afd_b.writable().await.unwrap().clear_ready();
tokio::select! {
biased;
_ = tokio::time::sleep(Duration::from_millis(10)) => {},
_ = afd_a.readable() => panic!("Unexpected readable state"),
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:6 | // Explicitly clear the ready state
guard.clear_ready();
let readable = afd_a.readable();
tokio::pin!(readable);
tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from_millis(10)) => {}
}
b.write_all(b"0").unwrap();
// We can observe the... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:7 | // Read from the other side; we should become writable now.
drain(&b);
let _ = writable.await.unwrap();
}
#[derive(Debug)]
struct ArcFd<T>(Arc<T>);
impl<T: AsRawFd> AsRawFd for ArcFd<T> {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}
#[tokio::test]
async fn drop_closes() {
let (a,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:8 | // Drop closure behavior is delegated to the inner object
let (a, mut b) = socketpair();
let arc_fd = Arc::new(a);
let afd_a = AsyncFd::new(ArcFd(arc_fd.clone())).unwrap();
std::mem::drop(afd_a);
assert_eq!(
ErrorKind::WouldBlock,
b.read(&mut [0]).err().unwrap().kind()
);
s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:9 | // Should clear the readable state
let _ = guard.try_io(|_| io::Result::<()>::Err(ErrorKind::WouldBlock.into()));
// Assert not readable
let readable = afd_a.readable();
tokio::pin!(readable);
tokio::select! {
_ = readable.as_mut() => panic!(),
_ = tokio::time::sleep(Duration::from... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_async_fd.rs:10 | guard.unwrap().clear_ready()
},
_ = notify_barrier => unreachable!(),
}
std::mem::drop(afd_a);
};
tasks.push(tokio::spawn(f));
}
let mut all_tasks = futures::future::try_join_all(tasks);
tokio::select! {
r = std::pin::Pin::n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_fd.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/tests/io_async_fd.rs | 361 | 420 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.