hughsie / libgusb

GUsb is a GObject wrapper for libusb1
GNU Lesser General Public License v2.1
25 stars 21 forks source link

device: Fix cancellation if cancellable is already cancelled #42

Closed benzea closed 3 years ago

benzea commented 4 years ago

libusb can only handle cancellation if the transfer is already in-flight. However, g_cancellable_connect will immediately call the callback and then libusb_cancel_transfer when the cancellable is already cancelled at the time the transfer is submitted.

Move the cancellation registration to after transfer submission to avoid ordering issues. Also avoid even submitting the transfer if the cancellable is already cancelled to begin with.

hughsie commented 4 years ago

LGTM, @nacho?

nacho commented 3 years ago

Thanks