@@ -61,39 +61,10 @@ async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
61
61
from : Rc < A > ,
62
62
to : Rc < B > ,
63
63
dbg_name : & ' static str ,
64
- direction : & ' static str ,
65
- stats_interval : Option < Duration > ,
66
64
bytes_written : Arc < AtomicUsize > ,
67
65
) -> Result < ( ) , std:: io:: Error > {
68
- // For statistics
69
- let mut bytes_out: usize = 0 ;
70
- let mut bytes_out_last: usize = 0 ;
71
- let mut report_time = Instant :: now ( ) ;
72
-
73
66
let mut buf = vec ! [ 0u8 ; BUFFER_LEN ] ;
74
67
loop {
75
- // Handle stats printing
76
- if stats_interval. is_some ( ) && report_time. elapsed ( ) > stats_interval. unwrap ( ) {
77
- let transferred_total = ByteSize :: b ( bytes_out. try_into ( ) . unwrap ( ) ) ;
78
- let transferred_last = ByteSize :: b ( bytes_out_last. try_into ( ) . unwrap ( ) ) ;
79
-
80
- let speed: u64 =
81
- ( bytes_out_last as f64 / report_time. elapsed ( ) . as_secs_f64 ( ) ) . round ( ) as u64 ;
82
- let speed = ByteSize :: b ( speed) ;
83
-
84
- info ! (
85
- "{} {} transfer: {:#} ({:#}/s), {:#} total" ,
86
- NAME ,
87
- direction,
88
- transferred_last. to_string_as( true ) ,
89
- speed. to_string_as( true ) ,
90
- transferred_total. to_string_as( true ) ,
91
- ) ;
92
-
93
- report_time = Instant :: now ( ) ;
94
- bytes_out_last = 0 ;
95
- }
96
-
97
68
// things look weird: we pass ownership of the buffer to `read`, and we get
98
69
// it back, _even if there was an error_. There's a whole trait for that,
99
70
// which `Vec<u8>` implements!
@@ -116,11 +87,7 @@ async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
116
87
let n = res?;
117
88
debug ! ( "{}: after write, {} bytes" , dbg_name, n) ;
118
89
// Increment byte counters for statistics
119
- if stats_interval. is_some ( ) {
120
- bytes_written. fetch_add ( n, Ordering :: Relaxed ) ;
121
- bytes_out += n;
122
- bytes_out_last += n;
123
- }
90
+ bytes_written. fetch_add ( n, Ordering :: Relaxed ) ;
124
91
125
92
// Later is now, we want our full buffer back.
126
93
// That's why we declared our binding `mut` way back at the start of `copy`,
@@ -247,16 +214,12 @@ pub async fn io_loop(
247
214
file. clone ( ) ,
248
215
stream. clone ( ) ,
249
216
"USB" ,
250
- "📲 car to phone" ,
251
- stats_interval,
252
217
stream_bytes. clone ( ) ,
253
218
) ) ;
254
219
let mut from_stream = tokio_uring:: spawn ( copy (
255
220
stream. clone ( ) ,
256
221
file. clone ( ) ,
257
222
"TCP" ,
258
- "📱 phone to car" ,
259
- stats_interval,
260
223
file_bytes. clone ( ) ,
261
224
) ) ;
262
225
0 commit comments