add the call to the CancelIo function #755
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#755
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
github.com/libusb/hidapi@f18d2c0768/windows/hid.c (L1129C3-L1133C4)This piece of if-judgment code needs to add the call to the CancelIo function. Otherwise, after WaitForSingleObject times out and returns, WriteFile may fail with a certain probability and keep being stuck in the IO_PENDING state. It is necessary to add the CancelIo operation to continue sending data normally.
eg :
@jianweihao how did you end up checking that piece of code? Did you happen to reproduce the issue?
And there is a problem adding
CancelIobeforeregister_winapi_error...Yes, we have the logic for switching USB HID devices, which triggers USB plug-in and removal during use. This is when the issue occurs. After calling the CancelIo function, the problem is resolved.
Can you try this hotplug branch? Thank. The current main branch does not really support hotplug.
https://github.com/libusb/hidapi/tree/connection-callback
This branch did not modify the code of hid_write. How does it handle the plug-in and removal logic? I'm very sorry because the modification was made 11 months ago. I can't find the equipment to reproduce the problem now, so I can't assist in verifying whether this branch can solve the problem.
I'm pretty sure you'd hit the same issue with
hid_writein that branch. I believe @mcuee wants to point out that since you're handling the hot plug/unplug scenarios for your devices, you should have some means to detect the removal/insertion of the device, so instead of making up something of your own, you might as well try that branch.Thank you for your reply. I will do my best to locate the problematic device for testing. However, this process may take a considerable amount of time. Could you please evaluate the rationality of this change from a code perspective? I would be extremely grateful.