Skip to content

Commit 690dcb8

Browse files
committed
fix(server): send FIN to void stream reset by peer
1 parent a4e526c commit 690dcb8

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

tuic-quinn/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ impl Connect {
441441
let recv_res = self.recv.stop(error_code);
442442
(send_res, recv_res)
443443
}
444+
445+
/// Tx: send FIN mark
446+
/// Rx: refuse accepting data
447+
pub fn finish(&mut self) -> (Result<(), ClosedStream>, Result<(), ClosedStream>) {
448+
let send_res = self.send.finish();
449+
let recv_res = self.recv.stop(VarInt::from_u32(0));
450+
(send_res, recv_res)
451+
}
444452
}
445453

446454
impl AsyncRead for Connect {

tuic-server/src/connection/handle_task.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ impl Connection {
6262
// a -> b tx
6363
// a <- b rx
6464
let (tx, rx, err) = exchange_tcp(&mut conn, &mut stream).await;
65-
66-
_ = conn.reset(ERROR_CODE);
65+
if err.is_some() {
66+
_ = conn.reset(ERROR_CODE);
67+
} else {
68+
_ = conn.finish();
69+
}
6770
_ = stream.shutdown().await;
6871

6972
let uuid = self

0 commit comments

Comments
 (0)