Linux hidraw hotplug: optional monitor auto-recovery after a udev-monitor failure #828
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#828
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the linux/hidraw hotplug monitor's udev netlink socket fails unrecoverably (
POLLERR/POLLHUP/POLLNVALbeyond theENOBUFSretry bound), the backend (#822) now stops cleanly: it marks the monitor dead, fabricates noDEVICE_LEFT, leaves the device cache and the application's open handles intact, and refuses new registrations. Existing callbacks simply stop receiving events. Losing the event transport is not evidence that the devices left, so this is the safe, honest behavior.An earlier attempt to instead auto-recover (rebuild the monitor, re-enumerate, diff against the cache, emit only real deltas) was dropped because it could not be made correct. During the outage window a cached device
Acan be unplugged and a different deviceBplugged into the same/dev/hidrawN; the reconcile has no stable per-connection identity to tell "Astill present" from "Agone,Barrived", so for serial-less devices bothLEFT(A)andARRIVED(B)are lost. The re-enumeration also has to be strictly all-or-nothing, or a partial scan fabricates spuriousLEFTs.Recording as a possible future enhancement: auto-recovery would need (1) a stable per-connection identity that survives an outage (e.g. from sysfs/udev properties) and (2) an all-or-nothing re-enumeration before it could emit deltas safely. Until then, stop-cleanly is correct.
Drafted with Claude Code.