wayland: treat flush WouldBlock as recoverable back-pressure#4564
Closed
johannesCmayer wants to merge 1 commit intorust-windowing:masterfrom
Closed
wayland: treat flush WouldBlock as recoverable back-pressure#4564johannesCmayer wants to merge 1 commit intorust-windowing:masterfrom
johannesCmayer wants to merge 1 commit intorust-windowing:masterfrom
Conversation
When the kernel socket send buffer (`SO_SNDBUF`) saturates under client write bursts, `wl_display.flush()` returns `WaylandError::Io(WouldBlock)`. libwayland documents this as recoverable: poll(POLLOUT) on the display fd and retry on the next iteration. Previously every flush error — including this transient back-pressure case — was treated as fatal and called `set_exit_code(1)`, killing the event loop on inputs that should have been absorbed naturally. Match on the flush result, ignore `Io(WouldBlock)`, propagate other errors. Mirrors the pattern in Smithay/calloop-wayland-source's flush_queue, which already handles this distinction correctly. Reproduces with high client→server request bursts (e.g. ~4000 xdg_toplevel.set_title/set_size requests in 60ms from multiple threads). After the fix, the same workload succeeds without exiting the loop.
Author
|
The two failing checks ( All Wayland-specific checks (stable / 1.85 / nightly) pass. |
Member
|
Well, if you submit AI generated code, please at least state so. Also, I'll let you know that there's other way to fix that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a long-standing wayland event-loop bug where any error from
connection.flush()is treated as fatal.WaylandError::Io(WouldBlock)returned from EAGAIN on the wayland socket is recoverable
back-pressure, not a protocol error, and should be retried on the next
loop iteration rather than calling
set_exit_code(1).This matches the pattern already used by
calloop-wayland-source'sflush_queueand is consistent with libwayland's documented contract for
wl_display_flush.Reproducer
A client that issues many wayland requests in a tight burst — e.g.
~4000
xdg_toplevel.set_title/set_sizecalls within 60 ms frommultiple threads — saturates the kernel SO_SNDBUF (~208 KiB by default).
The next
wl_display.flush()returnsWaylandError::Io(WouldBlock)and the event loop currently exits with code 1.
After this fix, the same workload completes cleanly: the next loop
iteration's
poll(POLLOUT)drains the buffer and the next flushsucceeds.
Test plan
stress workload that previously killed the loop in ~80 ms now
runs 25,000 requests in under 1 s without errors.
Notes
cargo +nightly fmt --check(nightly rustfmt 1.9.0):the added code is fmt-clean. There is some pre-existing import-order
drift in upstream master unrelated to this fix; not touched here to
keep the PR focused.
Checklist (winit PR template)
changelogmodulebug fix