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.
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.