Skip to content

Commit

Permalink
fix(server): send FIN to void stream reset by peer
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Jan 24, 2025
1 parent a4e526c commit 690dcb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tuic-quinn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,14 @@ impl Connect {
let recv_res = self.recv.stop(error_code);
(send_res, recv_res)
}

/// Tx: send FIN mark
/// Rx: refuse accepting data
pub fn finish(&mut self) -> (Result<(), ClosedStream>, Result<(), ClosedStream>) {
let send_res = self.send.finish();
let recv_res = self.recv.stop(VarInt::from_u32(0));
(send_res, recv_res)
}
}

impl AsyncRead for Connect {
Expand Down
7 changes: 5 additions & 2 deletions tuic-server/src/connection/handle_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ impl Connection {
// a -> b tx
// a <- b rx
let (tx, rx, err) = exchange_tcp(&mut conn, &mut stream).await;

_ = conn.reset(ERROR_CODE);
if err.is_some() {
_ = conn.reset(ERROR_CODE);
} else {
_ = conn.finish();
}
_ = stream.shutdown().await;

let uuid = self
Expand Down

0 comments on commit 690dcb8

Please sign in to comment.