Skip to content
Closed
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
1 change: 0 additions & 1 deletion quest/m1/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ because `main` assigned 0x3A to NOT_FETCHABLE first.
- [Token in band](/quest/m1/auth/token-in-band.md) - the credential can leave
the URL: a session starts on what the URL carried and its AUTH streams add
the rest, with the URL kept for peers without the AUTH stream
- [Join revocation](/quest/m1/auth/join-revocation.md) - a revoked grant ends our
subscription even while its joining FETCH waits for request-ID credit

## Related
Expand Down
29 changes: 0 additions & 29 deletions quest/m1/auth/join-revocation.md

This file was deleted.

28 changes: 26 additions & 2 deletions rs/moq-net/src/ietf/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub(crate) fn initial_max_request_id(window: u64, peer_client: bool) -> u64 {

struct ControlState {
request_id_next: RequestId,
/// A legacy request header must finish before a later ID can be allocated.
request_id_sending: bool,
/// None means no flow control (draft17 removed MaxRequestId).
request_id_max: Option<RequestId>,
/// The peer's requests, flow controlled on drafts 14 to 16 only.
Expand Down Expand Up @@ -106,11 +108,21 @@ pub(super) struct Control {
state: kio::Shared<ControlState>,
}

/// The session must keep a committed legacy header alive until this hold ends.
pub(super) struct RequestSend(Control);

impl Drop for RequestSend {
fn drop(&mut self) {
self.0.state.lock().request_id_sending = false;
}
}

impl Control {
pub fn new(request_id_max: Option<RequestId>, client: bool) -> Self {
Self {
state: kio::Shared::new(ControlState {
request_id_next: if client { RequestId(0) } else { RequestId(1) },
request_id_sending: false,
request_id_max,
incoming: None,
// The peer takes the other parity: a client's IDs are even, a server's odd.
Expand Down Expand Up @@ -222,7 +234,15 @@ impl Control {
Poll::Ready(RequestId(incoming.max))
}

/// Allocate the next request_id, blocking until MAX_REQUEST_ID allows it.
/// Hold later allocations until an already allocated legacy header is sent.
pub fn sending(&self) -> RequestSend {
let mut state = self.state.lock();
debug_assert!(!state.request_id_sending);
state.request_id_sending = true;
RequestSend(self.clone())
}

/// Allocate the next request_id once credit and the committed header allow it.
///
/// `runtime` arms the give-up timer, so the wait cannot outlive the caller's
/// clock.
Expand All @@ -235,7 +255,11 @@ impl Control {
None => true,
Some(max) => state.request_id_next < max,
};
if allowed { Poll::Ready(()) } else { Poll::Pending }
if allowed && !state.request_id_sending {
Poll::Ready(())
} else {
Poll::Pending
}
});

if let Poll::Ready(mut state) = allowed {
Expand Down
Loading
Loading