diff --git a/src/common/conf.rs b/src/common/conf.rs index 9c43509..0bc94fd 100644 --- a/src/common/conf.rs +++ b/src/common/conf.rs @@ -53,7 +53,7 @@ impl Config { addr: cli.addr.clone(), mode: cli.mode.clone(), threads: cli.threads, - timeout: Duration::from_millis(DEFAULT_TIMEOUT_LEN) + timeout: Duration::from_millis(DEFAULT_TIMEOUT_LEN), } } } diff --git a/src/main.rs b/src/main.rs index 786a4ae..f0f5acc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ async fn main() -> Result<()> { #[cfg(feature = "server")] if cli.server { info!("starting server"); - return Server::build(cfg).await?.run().await + return Server::build(cfg).await?.run().await; } // implicit else, so we can work without the server feature info!("starting client"); diff --git a/src/server/mod.rs b/src/server/mod.rs index f53d857..5508799 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,16 +1,15 @@ #![cfg(feature = "server")] use std::{net::SocketAddr, time::Duration}; -use anyhow::{Result, anyhow}; +use anyhow::{anyhow, Result}; use libpt::{ bintols::display::humanbytes, - log::{error, info, trace, warn, debug}, + log::{debug, error, info, trace}, }; use threadpool::ThreadPool; use tokio::{ - io::{AsyncBufRead, AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader, Interest}, - net::{self, TcpListener, TcpSocket, TcpStream}, - select, + io::{AsyncReadExt, BufReader}, + net::{TcpListener, TcpStream}, time::timeout, }; @@ -44,7 +43,7 @@ impl Server { } } - async fn handle_stream(&self, mut stream: (TcpStream, SocketAddr)) -> Result<()> { + async fn handle_stream(&self, stream: (TcpStream, SocketAddr)) -> Result<()> { info!("start handling stream {:?}", stream.1); let mut buf = Vec::new(); let mut reader = BufReader::new(stream.0); @@ -81,8 +80,9 @@ impl Server { trace!("loop"); len = match timeout(self.cfg.timeout, reader.read(buf)).await { Ok(inner) => { - trace!("Read for len: {inner:?}"); 0 - }, + trace!("Read for len: {inner:?}"); + 0 + } Err(err) => { error!("timeout while reading: {err}"); return Err(err.into()); @@ -90,8 +90,7 @@ impl Server { }; if self.should_end(&buf) { return Ok(len); - } - else { + } else { // ????????? failsafe += 1; }