test(broker): check a client with a full descriptor table names its own limit

Closed
KI
20d ago
+86-4

Problem

The mutants run on #109 (job) found a new miss on macOS, in code from #102:

crates/fsgate/src/broker.rs: replace match guard descriptors == Descriptors::Refuse with true in read_frame

The mutants workflow runs only when its setup changes, so it had not run since #102 added that guard.

Root cause

When the descriptors a message carries do not fit in the receiver's table, macOS fails recvmsg with EMFILE or EMSGSIZE. read_frame turns that into a malformed-frame error only for the broker, which refuses descriptors on requests (Descriptors::Refuse). A client accepts them, and passes the OS error on. #102's test covers the broker side. Nothing covered the client side, so a guard of true went unnoticed. With it, a client whose own table is full reports "peer attached more descriptors than could be received" and blames the broker for the client's limit.

Change

A test in broker_attached_descriptors.rs, the binary that already lowers the descriptor limit under its SERIAL lock. A fake broker queues an open response carrying one descriptor. The client's table is filled up to a lowered limit, and open runs:

  • On macOS the error names EMFILE ("Too many open files") and not "could be received".
  • On Linux, which reports the message truncated instead of failing recvmsg, the error is the truncation one, since the client cannot tell its own limit from a broker that sent too many.
  • Either way the next request fails closed, asking for a new connection.

The module doc now says the binary also covers a descriptor a client cannot receive. No code changes.

Verification

On macOS with Rust 1.99.1:

  • The new test passes. With the mutant applied by hand (the guard replaced with true), it fails: broker connection lost (peer attached more descriptors than could be received); all filesystem operations fail closed. broker.rs was restored afterwards.
  • cargo test --locked: 136 passed. cargo fmt --all --check passed, cargo clippy --locked --all-targets -- -D warnings is clean on macOS and for x86_64-unknown-linux-gnu, and cargo +1.85.0 check --locked --all-targets passed.

Not verified locally: the Linux branch of the test, which expects MSG_CTRUNC; this PR's CI runs it. This PR does not touch the mutants setup, so the mutants workflow does not run here. #109 reruns it once this is merged into it.

Documentation and release

None needed; no behavior changes.


Summary by cubic

Adds a test confirming that a client with a full descriptor table fails its requests with an error naming its own limit, and later requests fail closed. Previously only the broker side was covered, letting a mutant in read_frame go unnoticed on macOS. No behavior changes.