On Jul 22, 2013, at 8:28 AM, Alan Stern <st...@rowland.harvard.edu> wrote:

> On Sun, 21 Jul 2013, Nathan Hjelm wrote:
> 
>> On Jul 21, 2013, at 8:11 PM, Alan Stern <st...@rowland.harvard.edu> wrote:
>> 
>>> On Sun, 21 Jul 2013, Nathan Hjelm wrote:
>>> 
>>>> A little more detail about what is happening in this case. When the
>>>> device gets disconnected the hotplug backend calls
>>>> usbi_handle_disconnect which then �completes� (makes all outstanding
>>>> transfers as failed) all in-flight transfers. The darwin backend then
>>>> gets notification for the OS that transfer(s) have failed. This is
>>>> tricky to deal with because the user may have: freed the transfer,
>>>> released the device, etc. I think the best course of action is to
>>>> leave the hotplug backend code in place and �complete" any
>>>> outstanding transfers and then ignore the completion callback from
>>>> the OS. I should have the patch ready later today or sometime
>>>> tomorrow.
>>> 
>>> Are you sure this is the best approach?  IMO it would make more sense
>>> to mark the device as gone when the disconnect notification is
>>> received, but leave the transfers intact.  They will soon fail all by
>>> themselves, and the OS completion callbacks can be handled in the usual
>>> way.  After all the transfers are gone, then it will be safe to finish
>>> the disconnection procedure.
>> 
>> Thinking about it you are correct. It would be simple enough: ref the
>> device in darwin_submit_transfer and deref the device when the
>> completion callback happens. My real concern is what happens in Linux
>> when a device disconnects? Do you get notification for each pending
>> transaction? If not I can add a capability flag to indicate that the OS
>> will handle completion of the cancelled transfers.
> 
> In Linux, when a device connects there are no special notifications for
> each transfer.  Pending transfers are automatically cancelled by the
> kernel, and they complete in the usual way but with a status code of
> -ENODEV.  In addition, the kernel refuses to accept new transfer 
> submissions.

Ok, so how about this:

1) Remove the code from hotplug.c:195-207 since the completion callbacks are 
redundant. We will get them from the backend in both the Linux and OSX case. We 
can revisit when Windows hotplug support is added.

2) Make libusb_submit_transfer reference the device and 
usbi_handle_transfer_completion dereference the device.

-Nathan 


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to