Skip to content

Commit

Permalink
remove assumption about constantly being ready
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej committed Sep 2, 2023
1 parent b55690e commit f37a7b1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
14 changes: 1 addition & 13 deletions tokio/tests/tcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::{TcpListener, TcpStream};
use tokio::try_join;
use tokio_test::task;
use tokio_test::{assert_ok, assert_pending, assert_ready_ok};
use tokio_test::{assert_ok, assert_pending};

use std::io;
use std::task::Poll;
Expand Down Expand Up @@ -57,10 +57,6 @@ async fn try_read_write() {

// Fill the write buffer using non-vectored I/O
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write(DATA) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down Expand Up @@ -98,10 +94,6 @@ async fn try_read_write() {
// Fill the write buffer using vectored I/O
let data_bufs: Vec<_> = DATA.chunks(10).map(io::IoSlice::new).collect();
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write_vectored(&data_bufs) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down Expand Up @@ -313,10 +305,6 @@ async fn try_read_buf() {

// Fill the write buffer
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write(DATA) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down
14 changes: 1 addition & 13 deletions tokio/tests/uds_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::task::Poll;

use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::{UnixListener, UnixStream};
use tokio_test::{assert_ok, assert_pending, assert_ready_ok, task};
use tokio_test::{assert_ok, assert_pending, task};

use futures::future::{poll_fn, try_join};

Expand Down Expand Up @@ -92,10 +92,6 @@ async fn try_read_write() -> std::io::Result<()> {

// Fill the write buffer using non-vectored I/O
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write(msg) {
Ok(n) => written.extend(&msg[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down Expand Up @@ -133,10 +129,6 @@ async fn try_read_write() -> std::io::Result<()> {
// Fill the write buffer using vectored I/O
let msg_bufs: Vec<_> = msg.chunks(3).map(io::IoSlice::new).collect();
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write_vectored(&msg_bufs) {
Ok(n) => written.extend(&msg[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down Expand Up @@ -329,10 +321,6 @@ async fn try_read_buf() -> std::io::Result<()> {

// Fill the write buffer
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());

match client.try_write(msg) {
Ok(n) => written.extend(&msg[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
Expand Down

0 comments on commit f37a7b1

Please sign in to comment.