Skip to content

Commit af30102

Browse files
committed
io_uring: debug/err: fix endpoint names (logical name was incorrect for to)
1 parent f5f49d0 commit af30102

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/io_uring.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,23 @@ impl Endpoint<TcpStream> for TcpStream {
6666
async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
6767
from: Rc<A>,
6868
to: Rc<B>,
69-
dbg_name: &'static str,
69+
dbg_name_from: &'static str,
70+
dbg_name_to: &'static str,
7071
bytes_written: Arc<AtomicUsize>,
7172
) -> Result<()> {
7273
let mut buf = vec![0u8; BUFFER_LEN];
7374
loop {
7475
// things look weird: we pass ownership of the buffer to `read`, and we get
7576
// it back, _even if there was an error_. There's a whole trait for that,
7677
// which `Vec<u8>` implements!
77-
debug!("{}: before read", dbg_name);
78+
debug!("{}: before read", dbg_name_from);
7879
let retval = from.read(buf);
7980
let (res, buf_read) = timeout(READ_TIMEOUT, retval)
8081
.await
81-
.map_err(|e| -> String { format!("{} read: {}", dbg_name, e) })?;
82+
.map_err(|e| -> String { format!("{} read: {}", dbg_name_from, e) })?;
8283
// Propagate errors, see how many bytes we read
8384
let n = res?;
84-
debug!("{}: after read, {} bytes", dbg_name, n);
85+
debug!("{}: after read, {} bytes", dbg_name_from, n);
8586
if n == 0 {
8687
// A read of size zero signals EOF (end of file), finish gracefully
8788
return Ok(());
@@ -90,13 +91,13 @@ async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
9091
// The `slice` method here is implemented in an extension trait: it
9192
// returns an owned slice of our `Vec<u8>`, which we later turn back
9293
// into the full `Vec<u8>`
93-
debug!("{}: before write", dbg_name);
94+
debug!("{}: before write", dbg_name_to);
9495
let retval = to.write(buf_read.slice(..n)).submit();
9596
let (res, buf_write) = timeout(READ_TIMEOUT, retval)
9697
.await
97-
.map_err(|e| -> String { format!("{} write: {}", dbg_name, e) })?;
98+
.map_err(|e| -> String { format!("{} write: {}", dbg_name_to, e) })?;
9899
let n = res?;
99-
debug!("{}: after write, {} bytes", dbg_name, n);
100+
debug!("{}: after write, {} bytes", dbg_name_to, n);
100101
// Increment byte counters for statistics
101102
bytes_written.fetch_add(n, Ordering::Relaxed);
102103

@@ -253,12 +254,14 @@ pub async fn io_loop(
253254
file.clone(),
254255
stream.clone(),
255256
"USB",
257+
"TCP",
256258
stream_bytes.clone(),
257259
));
258260
let mut from_stream = tokio_uring::spawn(copy(
259261
stream.clone(),
260262
file.clone(),
261263
"TCP",
264+
"USB",
262265
file_bytes.clone(),
263266
));
264267

0 commit comments

Comments
 (0)