Repository navigation
Description
What happens
Two sites in ConnectionH2::flush_pending_control_frames set the WRITABLE event bit by hand:
lib/src/protocol/mux/h2.rs:3271 self.readiness.event.insert(Ready::WRITABLE); // WINDOW_UPDATE-drain stage
lib/src/protocol/mux/h2.rs:3334 self.readiness.event.insert(Ready::WRITABLE); // RST_STREAM-drain stage
Readiness::signal_pending_write (lib/src/lib.rs) does the same thing and proves it:
pub fn signal_pending_write(&mut self) {
// Snapshot the unrelated bits (everything but WRITABLE) so we can prove
// we flipped exactly the WRITABLE bit. `Ready` exposes no `!`, so mask on
// the public `.0` word.
let other_event_before = Ready(self.event.0 & !Ready::WRITABLE.0);
self.event.insert(Ready::WRITABLE);
debug_assert!(
self.event.is_writable(),
"signal_pending_write must set the WRITABLE event bit"
);
...
}The two debug_assert!s establish that the call set WRITABLE and disturbed nothing else. The hand-rolled sites get neither.
Why it matters
No behaviour difference today — both spellings touch the event bit only, and insert cannot clear a neighbouring bit. This is a missing guard, not a live bug, so it is low severity.
It is worth fixing anyway because of which guard is missing. The event/interest distinction is a proven blind spot in this code: a regression test in the H2 sans-io stack asserted readiness.interest.is_writable() when the mechanism under test sets readiness.event, and stayed green when the production call it existed to check was deleted outright. signal_pending_write is the one place that distinction is written down and asserted. A site that bypasses it opts out of the only mechanical statement of the rule, and does so invisibly — grep signal_pending_write does not find it, so an audit of "every place we signal a pending write" silently misses these two.
Suggested fix
Replace both with self.readiness.signal_pending_write();, which removes the second spelling rather than documenting it. This is the repository's usual remedy for a fact stated twice.
If either site is deliberately not a pending-write signal — for instance if it means something narrower than "the socket has buffered data that will not generate a new epoll WRITABLE event" — then the right fix is the opposite one: say so in a comment at the site, because the two spellings currently look interchangeable and nothing records that they are not.
Also worth triaging, separately
Three more hand-rolled inserts exist in lib/src/protocol/proxy_protocol/relay.rs (:708, :1002, :1207), on backend_readiness. I have not checked whether those are production or test paths, or whether the helper is even reachable from there — they may be entirely legitimate. Noting them so a fix for the H2 pair does not leave a sweep half-done, which is its own recurring defect in this tree.
Provenance
Found as a byproduct while scoping a sans-io extraction slice, by an audit that was looking for something else. Not currently blocking any work.
Activity
refactor(mux-h2): re-arm the control-frame drains through signal_pend…
refactor(mux-h2): re-arm the control-frame drains through signal_pend…
refactor(mux-h2): re-arm the control-frame drains through signal_pend…
refactor(mux-h2): re-arm the control-frame drains through signal_pend…