Retire closed transport stream ids

This commit is contained in:
DuProcess
2026-07-09 19:49:56 -04:00
parent 68cf411143
commit 5c8bd68aa6
3 changed files with 303 additions and 38 deletions
+9 -1
View File
@@ -4986,7 +4986,9 @@ async fn run_terminal(
continue;
};
last_packet_at = Instant::now();
stream_pending_opens.remove(&ok.stream_id);
if stream_pending_opens.remove(&ok.stream_id).is_none() {
continue;
}
opened_streams.insert(ok.stream_id);
stream_send_credit.entry(ok.stream_id).or_insert(STREAM_INITIAL_WINDOW);
stream_next_send_offset.entry(ok.stream_id).or_insert(0);
@@ -5044,6 +5046,9 @@ async fn run_terminal(
};
last_packet_at = Instant::now();
let stream_id = data.stream_id;
if !opened_streams.contains(&stream_id) {
continue;
}
let (writes, consumed, received_offset) =
accept_stream_data(&mut stream_next_recv_offset, &mut stream_recv_pending, data);
if let Some(writer) = stream_writers.get_mut(&stream_id) {
@@ -5078,6 +5083,9 @@ async fn run_terminal(
continue;
};
last_packet_at = Instant::now();
if !opened_streams.contains(&adjust.stream_id) {
continue;
}
ack_stream_data(
&mut stream_sent_data,
&mut stream_send_credit,
+12 -4
View File
@@ -2053,6 +2053,9 @@ async fn handle_stream_data(
}
client.endpoint = peer;
client.last_seen = Instant::now();
if !client.opened_streams.contains(&data.stream_id) {
return Ok(());
}
let writer = client.stream_writers.get(&data.stream_id).cloned();
let (writes, consumed, received_offset) = accept_stream_data(client, data);
(writer, writes, consumed, received_offset)
@@ -2062,9 +2065,9 @@ async fn handle_stream_data(
let _ = writer.send(bytes).await;
}
}
// Always return flow-control credit, even when the stream's writer is already
// gone (closed/unknown). The peer debited its send window for these bytes, so
// skipping the adjust would wedge the stream at a permanent credit deficit.
// Always return flow-control credit for live streams, even when the stream's
// writer is already gone. The peer debited its send window for these bytes,
// so skipping the adjust would wedge the stream at a permanent credit deficit.
send_stream_window_adjust_to_client(
state,
socket,
@@ -2101,7 +2104,9 @@ async fn handle_stream_open_ok(
}
client.endpoint = peer;
client.last_seen = Instant::now();
client.stream_pending_opens.remove(&ok.stream_id);
if client.stream_pending_opens.remove(&ok.stream_id).is_none() {
return Ok(());
}
client.opened_streams.insert(ok.stream_id);
client
.stream_send_credit
@@ -2161,6 +2166,9 @@ async fn handle_stream_window_adjust(
}
client.endpoint = peer;
client.last_seen = Instant::now();
if !client.opened_streams.contains(&adjust.stream_id) {
return Ok(());
}
ack_stream_data(client, adjust.stream_id, adjust.received_offset);
}
flush_stream_pending_data_to_client(state, socket, packet.header.conn_id, adjust.stream_id)