Ticket #70 (closed defect: fixed)
device removal breaks internal state, making later libusb_open calls always fail
|Reported by:||hagg||Owned by:||stuge|
I am using libusb-1.0.8 on a linux 2.6.35-22 (Ubuntu 10.10).
When libusb_open_device_with_vid_pid(..) is called in a loop,
it tries to open the usb device until it is powered up (or connected).
When I power down (or disconnect) the device later, there is a 50:50 chance
that libusb "crashes", and it is not possible to open the device from that
loop again. The error message libusb_open_device_with_vid_pid(..) gives is:
libusb:error [__open_sysfs_attr] open /sys/bus/usb/devices/(null)/descriptors failed ret=-1 errno=2
When a 1-second-sleep is appended to the loop the error does not occur and
it is possible to power up/down the device several times without problems.
(race condition somewhere?)
The error occurs when I run the program as an unprivileged user (w/o permissions to open the device) as well as when I run it as root.
A minimal program to trigger the error, its output and dmesg output are appended.
comment:2 in reply to: ↑ 1 Changed 3 years ago by stuge
- Keywords linux added
- Summary changed from not possible to re-open a device that was switched off (while opened) to device removal breaks internal state, making later libusb_open calls always fail