Skip to main content

Module connection

Module connection 

Source
Expand description

One server-side HTTP/3 connection: SETTINGS, the control stream, GOAWAY.

§Shape

A connection is three things:

  • the three unidirectional streams this endpoint opens and then holds open for its lifetime – control, QPACK encoder, QPACK decoder;
  • a background task that serves everything the peer sends outside its request streams: its unidirectional streams, its control stream, and its HTTP Datagrams;
  • Connection::accept, which hands request streams to the caller.

The background task is what makes the peer’s SETTINGS usable the moment they arrive, and it is worth a paragraph because the alternative cost a release. h3 reads the control stream only while its accept future is being polled, so a caller had to sample the answer – and a CONNECT-UDP session started from the same breath as the handshake read a stale “datagrams not allowed” and stayed on the RFC 9297 capsule fallback, on a connection that opens one tunnel and keeps it, for good. Here the control stream has a reader of its own and the flag it writes is the very one the sessions hold (Connection::peer_datagrams), so there is no moment at which the peer’s answer is known and not yet acted on, and nothing to poll.

§HTTP Datagrams

That same task routes the peer’s HTTP Datagrams (RFC 9297), because what a datagram names is a request stream: the first varint of its payload is a Quarter Stream ID, which is a request stream’s id divided by four. A session claims one by asking its stream for a DatagramReceiver (Stream::datagrams) and holds the claim for exactly as long as it holds the receiver, so a stream that ends – through any of the half-dozen paths a tunnel can end through – takes its routing entry with it and nothing has to remember to deregister it (D79).

Only the receiving half is here. A datagram goes out on the [quinn::Connection] itself, which the UDP sessions hold anyway for the send-buffer and datagram-size questions they ask per packet, and which has no HTTP/3 in it to consult.

§How a connection error is signalled

RFC 9114 §8 defines an HTTP/3 connection error as a QUIC CONNECTION_CLOSE carrying the HTTP/3 error code, which is precisely [quinn::Connection::close]. So that call is the mechanism: there is no error to propagate between tasks, because closing the connection makes every operation on it fail on its own. The only thing that has to travel is the reason, which quinn overwrites with “closed locally” – so it is recorded on the way past and read back by Connection::accept.

Structs§

Connection
An accepted HTTP/3 connection.
DatagramReceiver
One session’s inbound HTTP Datagrams, and its claim on a Quarter Stream ID.

Constants§

INBOUND_QUEUE_DEPTH
Inbound datagrams buffered per session before packets start being dropped.