quic_dist_dispatch (quic v1.4.0)
View SourcePer-message stream routing for QUIC-distribution traffic.
Each call to erlang:dist_ctrl_get_data/1 returns either a complete distribution message (plain pass-through), the first fragment of a fragmented message, or a continuation fragment. This module classifies the byte buffer and picks a QUIC stream for it:
- Plain / first fragment with a {From, To} pair → hash the pair into the data-stream pool. - Continuation fragment → look up the SeqId recorded for the first fragment; route to the same stream. - Known control message with no principals (e.g. NODE_LINK) → first data stream (not stream 0; the receiver drops non-tick bytes there). - Anything we cannot parse → {fatal, Reason}; the caller exits the controller so net_kernel rebuilds.
Atom cache must be disabled on the connection (reject_flags = dist_util:strict_order_flags()); the parser assumes NumberOfAtomCacheRefs = 0 in fragment headers and a PASS_THROUGH (112) byte before plain control messages.
Summary
Functions
Classify the byte buffer returned by erlang:dist_ctrl_get_data/1.
Pick a stream for Data from the data-stream pool DataStreams. CtrlStream is the control stream id; currently unused but kept in the signature for future control-stream routing of system messages. Frags is the in-flight-fragments map, updated as fragments arrive.
Types
-type classify_result() :: {plain, extract_result()} | {first, SeqId :: non_neg_integer(), FragId :: non_neg_integer(), extract_result()} | {cont, SeqId :: non_neg_integer(), FragId :: non_neg_integer()} | {atom_cache_active, NumRefs :: pos_integer()} | not_control.
-type fragments_state() :: #{SeqId :: non_neg_integer() => stream_id()}.
-type stream_id() :: non_neg_integer().
Functions
-spec classify(binary()) -> classify_result().
Classify the byte buffer returned by erlang:dist_ctrl_get_data/1.
-spec pick_stream(Data :: binary(), DataStreams :: [stream_id()], CtrlStream :: stream_id(), Frags :: fragments_state()) -> {{ok, stream_id()}, fragments_state()} | {{fatal, term()}, fragments_state()}.
Pick a stream for Data from the data-stream pool DataStreams. CtrlStream is the control stream id; currently unused but kept in the signature for future control-stream routing of system messages. Frags is the in-flight-fragments map, updated as fragments arrive.
Returns {{ok, StreamId}, NewFrags} on success, or {{fatal, Reason}, Frags} when the buffer cannot be safely routed.