API for hotplug (was Re: ETAs for libusbx operability and first release?)

Vitali Lovich vlovich at gmail.com
Wed Feb 1 11:00:05 EST 2012


On Feb 1, 2012, at 6:17 AM, Hans de Goede wrote:

> Hi,
> 
> On 02/01/2012 03:13 PM, Xiaofan Chen wrote:
> 
> <snip>
> 
>>> The idea is indeed that behavior will not change at all for
>>> existing apps. Note that having an unplug callback will always be racy,
>>> so an app with hotplug support may very well see a couple of IO-s
>>> fail with ENODEV before getting the unplug callback. One may even
>>> get various other errors, the same happens to in kernel USB driver,
>>> simply because often the HUB port does not see the disconnect at the
>>> hardware level quickly enough, so the HCI may try to send a couple
>>> of USB packets to the disconnected device, and utterly fail with
>>> a variance of error codes.
>>> 
>> 
>> This is why I think it will get a bit of delay compared to the
>> no-hotplug libusb implementation, Am I right?
> 
> Currently an app using libusb won't notice an unplug *at all* until it
> tries to submit some new IO to the device. So for some apps the delay
> may be quite large.
Unless it polls the list of devices, which is the way I do it.  Additionally, I poll the list only on hotplug notifications.  It's hacky, but it works fine for the most part.


More information about the libusbx mailing list