Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions quest/m1/stream-credit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ which JS cannot raise; Chrome stalled at 103, Firefox at 100):
quest until #7670 merges.

- Decided 2026-11-07 (maintainer, /quest-plan from the API shape audit):
✅ delete Rust's `StreamCredit` hook too, with no replacement hook
([no-credit-hook](/quest/m1/stream-credit/no-credit-hook.md)). #7894's
✅ delete Rust's `StreamCredit` hook too, with no replacement hook: a
transport's open waits only for credit, writing a WebTransport header as
the stream's first data. #7894's
reversal removed the JS half; the Rust trait kept it because the open line
reads it. Not chosen: keeping the hook and recording why.

Expand All @@ -49,4 +50,3 @@ receiving every group, and nothing hanging.
## Required

- [Takeover](/quest/m1/stream-credit/takeover.md) - on lite-07 a higher-priority group takes over an acknowledged stream, and a group that lost its stream resumes
- [Transports report no stream credit](/quest/m1/stream-credit/no-credit-hook.md) - `StreamCredit` and the `poll::Session::stream_credit` hook are gone, and the open line infers a credit wait from its own state
29 changes: 0 additions & 29 deletions quest/m1/stream-credit/no-credit-hook.md

This file was deleted.

45 changes: 0 additions & 45 deletions rs/moq-net/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,6 @@ impl ReceiveWindow {
}
}

/// Which streams a session opens: one-way, or both ways.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Dir {
/// Unidirectional streams.
Uni,
/// Bidirectional streams.
Bi,
}

/// The streams a peer still lets this side open in one direction, as the transport last heard.
///
/// A peer grants a bounded number of streams, and an open beyond them waits for it to grant
/// more. A session reads this to tell an open waiting for that credit from one waiting on
/// anything else. See [`poll::Session::stream_credit`].
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct StreamCredit {
/// The streams this side may still open before the peer grants more.
pub available: u64,
/// Whether an open was refused for lack of credit since the peer last granted more, so
/// this side waits for the peer, as QUIC's STREAMS_BLOCKED says.
pub blocked: bool,
}

impl StreamCredit {
/// `available` streams left, `blocked` once an open was refused for lack of them.
pub fn new(available: u64, blocked: bool) -> Self {
Self { available, blocked }
}
}

/// Limits to change on a live session with [`poll::Session::set_limits`]. Each `None` leaves
/// its limit as it is.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
Expand Down Expand Up @@ -429,16 +398,6 @@ pub mod poll {
Err(super::LimitsError::Unsupported)
}

/// Return the peer's stream credit in `dir`, or `None` when the transport cannot say,
/// as a browser's WebTransport cannot.
///
/// Read whenever an open waits, so the session knows whether the peer's credit is what
/// it waits for.
fn stream_credit(&self, dir: super::Dir) -> Option<super::StreamCredit> {
let _ = dir;
None
}

/// Export 32 bytes of keying material from this session's handshake under `label` and
/// `context` (RFC 8446 section 7.5), or `None` when the transport has no exporter.
///
Expand Down Expand Up @@ -659,10 +618,6 @@ pub mod poll {
(**self).set_limits(limits)
}

fn stream_credit(&self, dir: super::Dir) -> Option<super::StreamCredit> {
(**self).stream_credit(dir)
}

fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]> {
(**self).export_keying_material(label, context)
}
Expand Down
24 changes: 3 additions & 21 deletions rs/moq-net/src/transport/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::task::{Poll, ready};

use bytes::{Buf, Bytes};

use super::open::{self, Open};
use super::open::{self, Dir, Open};
use super::poll::{self, SendOptions};
use super::{Address, CloseKind, Dir, Limits, LimitsError, Probe, ReceiveWindow, StreamCredit, Wire};
use super::{Address, CloseKind, Limits, LimitsError, Probe, ReceiveWindow, Wire};

/// A boxed [`poll::Boxable`] session, shared by every task that uses it.
#[derive(Clone)]
Expand All @@ -35,7 +35,7 @@ impl Session {
session,
});
Self {
opens: Arc::new(open::Lines::new(Arc::downgrade(&inner))),
opens: Default::default(),
inner,
closing: Default::default(),
work: Default::default(),
Expand Down Expand Up @@ -168,15 +168,6 @@ impl Shared<dyn ErasedSession> {
/// open: once it is gone, nothing is paused.
type Budget = Weak<Shared<dyn ErasedSession>>;

/// The transport a session's lines read the peer's stream credit from, which they never keep
/// open.
pub(super) type Transport = Weak<Shared<dyn ErasedSession>>;

/// The peer's stream credit in `dir`, or `None` once the transport is gone or cannot say.
pub(super) fn stream_credit(transport: &Transport, dir: Dir) -> Option<StreamCredit> {
transport.upgrade()?.session.stream_credit(dir)
}

/// A boxed transport error, keeping both code registries and the message.
#[derive(Debug)]
pub(crate) struct Error(Box<dyn super::Error>);
Expand Down Expand Up @@ -580,7 +571,6 @@ pub(super) trait ErasedSession: Send + Sync {
fn probe(&self) -> Option<Probe>;
fn receive_window(&self) -> Option<ReceiveWindow>;
fn set_limits(&self, limits: Limits) -> Result<(), LimitsError>;
fn stream_credit(&self, dir: Dir) -> Option<StreamCredit>;
fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]>;
}

Expand Down Expand Up @@ -722,10 +712,6 @@ impl<S: poll::Boxable> ErasedSession for S {
poll::Session::set_limits(self, limits)
}

fn stream_credit(&self, dir: Dir) -> Option<StreamCredit> {
poll::Session::stream_credit(self, dir)
}

fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]> {
poll::Session::export_keying_material(self, label, context)
}
Expand Down Expand Up @@ -931,10 +917,6 @@ impl poll::Session for Session {
self.inner.session.set_limits(limits)
}

fn stream_credit(&self, dir: Dir) -> Option<StreamCredit> {
self.inner.session.stream_credit(dir)
}

fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]> {
self.inner.session.export_keying_material(label, context)
}
Expand Down
38 changes: 1 addition & 37 deletions rs/moq-net/src/transport/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
use std::{
collections::VecDeque,
pin::Pin,
sync::{
Arc,
atomic::{AtomicBool, Ordering},
},
sync::Arc,
task::{Poll, ready},
time::Duration,
};
Expand Down Expand Up @@ -216,9 +213,6 @@ type Credit = Arc<Opened>;
#[derive(Default)]
struct Open {
count: usize,
/// Whether an open pended since a stream last returned its credit. Atomic, so a pending
/// open's read-only check sets it without waking itself.
blocked: AtomicBool,
}

/// Counted in an open-stream total until dropped.
Expand All @@ -228,7 +222,6 @@ impl Drop for Opened {
fn drop(&mut self) {
let mut open = self.0.lock();
open.count -= 1;
*open.blocked.get_mut() = false;
}
}

Expand All @@ -248,7 +241,6 @@ fn poll_credit(
if open.count < max {
return Poll::Ready(());
}
open.blocked.store(true, Ordering::Relaxed);
Poll::Pending
}) else {
return closed.map(Err);
Expand All @@ -257,18 +249,6 @@ fn poll_credit(
Poll::Ready(Ok(Some(Arc::new(Opened(open.clone())))))
}

/// What is left of `max` streams beyond those in `open`, unbounded without a `max`.
fn stream_credit(open: &kio::Shared<Open>, max: Option<usize>) -> super::StreamCredit {
let Some(max) = max else {
return super::StreamCredit::new(u64::MAX, false);
};
let open = open.read();
super::StreamCredit::new(
max.saturating_sub(open.count) as u64,
open.blocked.load(Ordering::Relaxed),
)
}

/// Streams and datagrams one side has yet to accept.
struct Incoming {
uni: kio::Queue<RecvStream>,
Expand Down Expand Up @@ -451,15 +431,6 @@ impl poll::Session for Session {
))
}

fn stream_credit(&self, dir: super::Dir) -> Option<super::StreamCredit> {
let outgoing = self.side.outgoing();
let config = &self.conn().config;
Some(match dir {
super::Dir::Uni => stream_credit(&outgoing.uni_open, config.max_concurrent_uni_streams),
super::Dir::Bi => stream_credit(&outgoing.bi_open, config.max_concurrent_bi_streams),
})
}

fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]> {
// Length-prefixed, so no label and context pair collides with another.
let lengths = [u8::try_from(label.len()).ok()?, u8::try_from(context.len()).ok()?];
Expand Down Expand Up @@ -821,7 +792,6 @@ mod tests {
task::{Wake, Waker},
};

use super::super::{Dir, StreamCredit};
use super::*;
use poll::{RecvStream as _, SendStream as _, Session as _};

Expand Down Expand Up @@ -948,19 +918,14 @@ mod tests {
..Default::default()
});
let open = |a: &Session, waiter: &kio::Waiter| a.poll_open_uni(waiter, Default::default());
let credit = |a: &Session| a.stream_credit(Dir::Uni).unwrap();
assert_eq!(credit(&a), StreamCredit::new(2, false));

// Streams the peer has not accepted yet hold credit too.
let mut finished = ready(open(&a, &noop())).unwrap();
let _reset = ready(open(&a, &noop())).unwrap();
assert_eq!(credit(&a), StreamCredit::new(0, false), "none refused yet");
let count = Arc::new(Count::default());
let waiter = kio::Waiter::new(Waker::from(count.clone()));
assert!(open(&a, &waiter).is_pending());
assert_eq!(count.0.load(Ordering::Relaxed), 0, "being blocked wakes nobody");
assert_eq!(credit(&a), StreamCredit::new(0, true));
assert!(!credit(&b).blocked, "each side blocks alone");

// Credit is per direction.
let _back = ready(open(&b, &noop())).unwrap();
Expand All @@ -973,7 +938,6 @@ mod tests {
assert!(open(&a, &waiter).is_pending(), "an unread FIN keeps the credit");
assert_eq!(ready(read(&mut recv, usize::MAX)).unwrap(), None);
assert!(count.0.load(Ordering::Relaxed) > 0);
assert_eq!(credit(&a), StreamCredit::new(1, false), "returned credit unblocks");
let _third = ready(open(&a, &noop())).unwrap();
assert!(open(&a, &noop()).is_pending());

Expand Down
Loading
Loading