[PATCH] linux: Don't report LIBUSB_ERROR_NOT_FOUND when cancelling unreaped urbs

Hans de Goede hdegoede at redhat.com
Sat Feb 11 04:51:08 EST 2012


Hi,

On 02/10/2012 06:51 PM, Vitali Lovich wrote:
> Shouldn't the correct behaviour be that libusb_cancel_transfer returns an error if the transfers have already completed?

I don't see this as an error condition:
1) Has the hardware done something unexpected -> no
2) Has the app using libusb done something unexpected -> no (the app cannot know the transfer has already completed)

Even if you disagree and see this as an error, it should use a different error code then the one
also used for: "yo, you stupid app, that transfer has already completed and its callback has been called, so you should know!"
which is what NOT_FOUND is also used for.

 > I'm thinking it's an error that reap_action gets set to CANCELLED.  I think it should remain unchanged when discard_urbs detects this scenario.

I agree, but I'm afraid that may break existing apps who rely on the old
behavior. For more on this see my discussion with Peter on the libusb-devel list.
I posted this patch to both the libusbx and libusb-devel lists, as I wanted
Peter's input and I wanted the libusbx people to be aware too, since I would
like to see a fix for this in our first release...  Sorry about the confusion
this creates, lets continue this discussion on the libusb-devel list, I go
into more details about why I think that not changing the reap_action
in this scenario may cause troubles, even though I agree it is the right
thing to do!

Regards,

Hans



More information about the libusbx mailing list