Skip to content

fix(io): re-point FfbForwarder at the fresh fd on device rebind - #464

Merged
BANANASJIM merged 1 commit into
mainfrom
fix/ffb-stale-fd-rebind
Jul 1, 2026
Merged

fix(io): re-point FfbForwarder at the fresh fd on device rebind#464
BANANASJIM merged 1 commit into
mainfrom
fix/ffb-stale-fd-rebind

Conversation

@BANANASJIM

Copy link
Copy Markdown
Owner

Bug

FfbForwarder captures devices[0]'s hidraw fd by value at init. On a sleep/wake rebind, closeDeviceIO closes the old fd and rebindDeviceIO swaps in a new one, but the forwarder kept the stale fd. After resume it wrote PID FFB reports to a closed (→ EBADF, forwarder permanently disabled) or recycled fd (→ wrong file). Only affects force_feedback backend="uhid" kind="pid" wheels that suspend/resume.

Fix

Add FfbForwarder.setPhysicalFd and call it from rebindDeviceIO to re-point at the new devices[0] fd, re-arming a forwarder that may have disabled itself on the stale fd.

Test plan

  • New regression test DeviceInstance: rebindDeviceIO re-points FfbForwarder at the fresh fd. Verified red→green: it fails on the unfixed code (physical_fd stuck on the old fd) and passes after the re-point.
  • Full Layer 0/1 suite green in the canonical Docker image (zig build test, exit 0).

FfbForwarder captures devices[0]'s hidraw fd by value at init. On a
sleep/wake rebind, closeDeviceIO closes the old fd and rebindDeviceIO
swaps in a new one, but the forwarder kept the stale fd — so after
resume it wrote PID FFB reports to a closed (or recycled) fd, either
silently disabling rumble or writing to the wrong file.

Add FfbForwarder.setPhysicalFd and call it from rebindDeviceIO to
re-point at the new devices[0] fd (and re-arm a self-disabled forwarder).
Only affects force_feedback backend="uhid" kind="pid" wheels.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@BANANASJIM, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b218bdb-b214-4de6-98ad-75eeb772b0a3

📥 Commits

Reviewing files that changed from the base of the PR and between 27895bb and 7ff9513.

📒 Files selected for processing (2)
  • src/device_instance.zig
  • src/io/ffb_forwarder.zig
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ffb-stale-fd-rebind

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BANANASJIM
BANANASJIM merged commit fa5b3f5 into main Jul 1, 2026
36 checks passed
@BANANASJIM
BANANASJIM deleted the fix/ffb-stale-fd-rebind branch July 1, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant