Skip to content

fix(raw): propagate EPIPE after exhausting sendReport retries#555

Open
jelmerdehen wants to merge 1 commit into
PixlOne:mainfrom
jelmerdehen:fix/raw-device-epipe-error
Open

fix(raw): propagate EPIPE after exhausting sendReport retries#555
jelmerdehen wants to merge 1 commit into
PixlOne:mainfrom
jelmerdehen:fix/raw-device-epipe-error

Conversation

@jelmerdehen
Copy link
Copy Markdown

Summary

The retry loop in RawDevice::sendReport:

for (int i = 0; i < max_write_tries && write(_fd, ...) == -1; ++i) {
    auto err = errno;
    if (err != EPIPE)
        throw std::system_error(...);
}

tolerates up to max_write_tries EPIPE returns. If every retry returns EPIPE the loop exits silently and the caller believes the report has been delivered. The HID++ layer then waits for a response that never comes, masking a stuck or disconnected device until io_timeout fires.

Fix

Track the last errno and throw the same std::system_error after the retry budget is spent.

Test plan

  • Builds cleanly.
  • Disconnect a device mid-write and confirm the caller sees EPIPE instead of waiting on io_timeout.

The retry loop in RawDevice::sendReport tolerated up to max_write_tries
EPIPE returns, but if every retry returned EPIPE the loop exited
silently and the caller believed the report had been delivered. The
HID++ layer would then sit waiting for a response that never came,
masking a stuck or disconnected device until the io_timeout fires.

Track the last errno and throw the same std::system_error after the
retry budget is spent, so callers learn the write actually failed.
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