On Tue Oct 20, 2026 at 7:08 PM JST, Alexandre Courbot wrote:
> `receive_msg` currently handles both the transport and RPC layers.
> Retire it and split its logic between the new `consume_element`, a
> transport-level method which passes the parsed message contents to a
> closure before advancing the CPU read pointer past it, and the
> already-existing `await_msg`, which calls `consume_element` with a
> closure matching the RPC message.
>
> This introduces a small behavioral change: a matched RPC message that is
> too short to contain the message component itself no longer stalls the
> queue. This behavior is justified because it fixes an inconsistency:
> unmatched RPC messages were always skipped, whereas matched RPC messages
> could block the queue if they were too short. While a misconstructed RPC
> message is a problem, it is not a fatal queue error as long as the
> transport framing and checksum are valid.
>
> Signed-off-by: Alexandre Courbot <[email protected]>
> ---

[...]

> -    /// Receive a message from the GSP.
> +    /// Wait for the next element on the message queue, pass it to `f`, 
> advance the read pointer
> +    /// past the message, and returns the result of `f`.
>      ///
> -    /// A message whose function code is `M::FUNCTION` is decoded and 
> returned. Any other message
> -    /// is logged as an event.
> -    ///
> -    /// The read pointer is always advanced past the message, regardless of 
> whether it matched.
> +    /// The read pointer advances regardless of whether `f` succeeds or not.
>      ///
>      /// # Errors
>      ///
>      /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes 
> available.
> -    /// - `EIO` if a message fails framing or checksum validation.
> -    /// - `ENOMSG` if the message was not the awaited reply.
> +    /// - `EIO` if a message fails framing or checksum validation. In this 
> case, the read pointer
> +    ///   does not advance and the queue is stalled. This is a fatal error.
>      ///
> -    /// Error codes returned by [`MessageFromGsp::read`] are propagated 
> as-is.
> -    fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M>
> -    where
> -        // This allows all error types, including `Infallible`, to be used 
> for `M::InitError`.
> -        Error: From<M::InitError>,
> -    {
> +    /// If an error is returned, then `f` has not been called.

optional nit: Clarify in a comment that w.r.t. `EIO` and `f` not being
called, that only applies for the outermost Err. i.e., we do have
R = Result<>, so we have Result<Result<>> but we're only talking about
the outer (transport) Result here. Maybe one way to clarify this is
that `R` contains the output of the message layer and may itself
be a Result<>, and this function returns a Result for the transport
layer. Not sure of the best way to phrase it but you know what I mean.

Reviewed-by: Eliot Courtney <[email protected]>

Reply via email to