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
+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)