From: Ian Jackson Date: Tue, 3 Aug 2021 23:07:28 +0000 (+0100) Subject: rx queue, missing boundaries X-Git-Tag: hippotat/1.0.0~365 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=659af4fac61f2257916a3d1cdfe22d59b2e03433;p=hippotat.git rx queue, missing boundaries Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index 56a6c6d..8e26414 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -184,7 +184,7 @@ async fn run_client( let mut req_num: ReqNum = 0; let tx_stream = ipif.stdout.take().unwrap(); - let rx_stream = ipif.stdin .take().unwrap(); + let mut rx_stream = ipif.stdin .take().unwrap(); let mut tx_stream = tokio::io::BufReader::new(tx_stream).split(SLIP_END); let mut packets: VecDeque> = default(); @@ -200,6 +200,12 @@ async fn run_client( async { loop { select! { + y = rx_stream.write_all_buf(&mut rx_queue), + if ! rx_queue.is_empty() => + { + let () = y.context("write rx data to ipif")?; + }, + data = tx_stream.next_segment(), if packets.is_empty() => { @@ -265,8 +271,6 @@ async fn run_client( }, |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e)); dbg!(&rx_queue); - // xxx do writing with - // tokio::io::AsyncWriteExt::write_all_buf } } } diff --git a/src/prelude.rs b/src/prelude.rs index c9c11be..6fffe92 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -36,7 +36,7 @@ pub use lazy_regex::{regex_is_match, regex_replace_all}; pub use log::{trace, debug, info, warn, error}; pub use structopt::StructOpt; pub use thiserror::Error; -pub use tokio::io::AsyncBufReadExt; +pub use tokio::io::{AsyncBufReadExt, AsyncWriteExt}; pub use tokio::pin; pub use tokio::select; pub use tokio::task;