Remove unnecessary send stream state

This commit is contained in:
Benjamin Saunders
2021-02-23 21:28:43 -08:00
committed by Dirkjan Ochtman
parent c2467fa61d
commit 2adc1bc3cc
2 changed files with 11 additions and 12 deletions
+2 -2
View File
@@ -715,8 +715,8 @@ impl Streams {
}
let id = frame.id;
self.unacked_data -= frame.offsets.end - frame.offsets.start;
stream.ack(frame);
if stream.state != SendState::DataRecvd {
if !stream.ack(frame) {
// The stream is unfinished or may still need retransmits
return;
}
+9 -10
View File
@@ -79,16 +79,17 @@ impl Send {
self.stop_reason = Some(error_code);
}
pub(super) fn ack(&mut self, frame: frame::StreamMeta) {
/// Returns whether the stream has been finished and all data has been acknowledged by the peer
pub(super) fn ack(&mut self, frame: frame::StreamMeta) -> bool {
self.pending.ack(frame.offsets);
if let SendState::DataSent {
ref mut finish_acked,
} = self.state
{
*finish_acked |= frame.fin;
if *finish_acked && self.pending.is_fully_acked() {
self.state = SendState::DataRecvd;
match self.state {
SendState::DataSent {
ref mut finish_acked,
} => {
*finish_acked |= frame.fin;
*finish_acked && self.pending.is_fully_acked()
}
_ => false,
}
}
@@ -157,8 +158,6 @@ pub(super) enum SendState {
DataSent { finish_acked: bool },
/// Sent RESET
ResetSent,
/// All sent data acknowledged
DataRecvd,
}
/// Reasons why attempting to finish a stream might fail