quic_dist_dispatch (quic v1.4.2)

View Source

Per-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

classify_result/0

-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.

extract_result/0

-type extract_result() ::
          {ok, From :: binary() | undefined, To :: binary() | undefined} |
          no_principals | unknown_dop | parse_error.

fragments_state/0

-type fragments_state() :: #{SeqId :: non_neg_integer() => stream_id()}.

stream_id/0

-type stream_id() :: non_neg_integer().

Functions

classify(_)

-spec classify(binary()) -> classify_result().

Classify the byte buffer returned by erlang:dist_ctrl_get_data/1.

pick_stream(Data, DataStreams, CtrlStream, Frags)

-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.