New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux hidraw: Occasional 'permission denied' when opening device #217
Comments
Does it only happen when enumerating twice per second? Does the percentage of failure depend on the delay between successive enumerations? In other words, if you extend the delay to 1s, does it fail 1 out of 20 times or is it still 1 out of 10? I'm thinking there should be a way to subscribe to udev events instead of constantly calling |
With the delay at 1 second the failure percentage goes way down. But with the delay at 100 ms, it happened more often than at 500 ms. Here's what I think is happening:
I think it fails more often when The root issue I see is that a device can be enumerated before the device node is actually ready to be opened. I see a I added a check with this call into |
…() returns it In hid_enumerate(), skip any devices which have not yet been initialized by udev (which includes setting permissions on the device node). Previously, a race condition was possible where hid_enumerate() could return a device that hid_open() could not open, because udev had not set permissions on the device node yet. This resolves issue 217, "Occasional 'permission denied' when opening device" (signal11#217)
… returns it In hid_enumerate(), skip any devices which have not yet been initialized by udev (which includes setting permissions on the device node). Previously, a race condition was possible where hid_enumerate() could return a device that hid_open() could not open, because udev had not set permissions on the device node yet. This resolves issue 217, "Occasional 'permission denied' when opening device" (signal11#217)
… returns it In hid_enumerate(), skip any devices which have not yet been initialized by udev (which includes setting permissions on the device node). Previously, a race condition was possible where hid_enumerate() could return a device that hid_open() could not open, because udev had not set permissions on the device node yet. This resolves issue 217, "Occasional 'permission denied' when opening device" (signal11#217)
My app runs
hid_enumerate()
every 500 ms, and callshid_open()
when a new device is enumerated.About 1 out of 10 times,
hid_open()
fails inhid_open_path()
, becauseopen()
fails withpermission denied
It looks like this is a race condition, trying to open
/dev/hidraw0
before udev has properly set permissions on it. I put in asystem()
call to dols -l <path>
afteropen()
fails, and this was the result:And even that result was not consistent, for several failures
ls
showed the correct final permissions.Is there any solution to this, other than putting a few hundred ms delay in between
hid_enumerate()
andhid_open()
?udev rule (in
/etc/udev/rules.d
)ATTRS{idVendor}=="2057", ATTRS{idProduct}=="0001",MODE="0666"
Ubuntu 14.04 32-bit running kernel 3.13.0-48-generic
The text was updated successfully, but these errors were encountered: