Skip to content

Commit

Permalink
chore: remove tcp timeout, it causes perceptible disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Jan 8, 2025
1 parent 51a667f commit d3a6b1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tuic-server/src/connection/handle_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Connection {
// a -> b tx
// a <- b rx
let (tx, rx, err) =
exchange_tcp(&mut conn, &mut stream, self.ctx.cfg.stream_timeout).await;
exchange_tcp(&mut conn, &mut stream).await;

_ = conn.reset(ERROR_CODE);
_ = stream.shutdown().await;
Expand Down
9 changes: 1 addition & 8 deletions tuic-server/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const BUFFER_SIZE: usize = 8 * 1024;

pub async fn exchange_tcp(
a: &mut tuic_quinn::Connect,
b: &mut tokio::net::TcpStream,
timeout: Duration,
b: &mut tokio::net::TcpStream
) -> (usize, usize, Option<eyre::Error>) {
let mut a2b = [0u8; BUFFER_SIZE];
let mut b2a = [0u8; BUFFER_SIZE];
Expand All @@ -16,15 +15,9 @@ pub async fn exchange_tcp(
let mut b2a_num = 0;

let mut last_err = None;
let mut timeout = tokio::time::interval(timeout);
timeout.reset();

loop {
tokio::select! {
_ = timeout.tick() => {
last_err = Some(eyre::eyre!("TCP stream timeout"));
break;
},
a2b_res = a.recv.read(&mut a2b) => match a2b_res {
Ok(Some(num)) => {
a2b_num += num;
Expand Down

0 comments on commit d3a6b1a

Please sign in to comment.