Skip to main content

write_in_order

Function write_in_order 

Source
async fn write_in_order(
    raw: &[u8],
    send: &mut SendStream,
    st: &mut StreamState<'_>,
    ctx: &ForwardCtx,
    report: &Reporter<'_>,
) -> Result<Flow, ProxyError>
Expand description

Write bytes the hook was never shown, keeping wire order — on an unshaped stream.

session.rs cannot enqueue on its own — DeferredEffects’s push is exec’s, so the ledger and the deque can only move together — so when something is already waiting the queue is drained at its release times first. The three callers are a stream header, an oversized object’s passthrough chunk and a bypassed stream’s bytes: none is addressable, and none may be reordered against an object the hook did defer.

On an empty queue — every session with no timing action, which is every Interest::NONE session — this is one is_empty() and the same send.write_all(&raw).await the byte pump does.

A shaped stream calls exec::enqueue_unshown instead, and must: this function would let these bytes escape the pacer, and the drain it runs first honours release times, so on a paced queue it would block the read arm for as long as the bucket took, inside a select! arm body that polls no other branch.