Skip to main content

drain_pending

Function drain_pending 

Source
async fn drain_pending(
    send: &mut SendStream,
    st: &mut StreamState<'_>,
    site: Site,
    shaped: Option<&ShapedStream>,
    ctx: &ForwardCtx,
    report: &Reporter<'_>,
) -> Result<Flow, ProxyError>
Expand description

Flush anything the hook deferred, honouring its release times, as a race against session cancellation.

The drain sits inside a select! arm body, which is not preemptible, so writing it as a plain loop would let a Hold on a gate nobody releases pin session teardown for up to EgressConfig::max_hold.

§shaped, and why it is a parameter rather than a None

This is the FIN path, and on the framed pipe the FIN path is the ordinary MoQT subgroup shape: header, a handful of objects, FIN. Every unit still queued when the source finishes is released by the drain below, which means every clamp and every expiry those units earn is decided there — so shaped is what turns those decisions into HoldClamped and Shaped { Expired } instead of into nothing. It was None-by-omission once, and the whole profile applied itself to the normal case in silence; shaping_reports_do_not_depend_on_a_fin is the gate.

None at the four callers that cannot produce a report: both control pipes install no scheduler, pipe_data_passthrough installs no scheduler, and write_in_order is reachable only behind pipe_data_framed’s shape.is_some() guard taking the other branch.