Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't re-open device after closing it with outstanding OVERLAPPED event #125

Closed
gwgill opened this issue Sep 27, 2023 · 2 comments
Closed
Assignees

Comments

@gwgill
Copy link

gwgill commented Sep 27, 2023

If a USB device is opened and a transfer started, but the device is then closed before calling GetOverlappedResult() on the OVERLAPPED object, it is not possible to re-open the device.
This can happen as a result of the process being terminated.
Re-plugging the device doesn't fix it.
Attempts to stop and re-start the UsbDk driver fail.
The only way to fix it is to re-boot the machine.
(Windows 10 22H2, UsbDk 1.00-22)

@gwgill
Copy link
Author

gwgill commented Sep 27, 2023

A partial work-around is to intercept process termination with (say) a sighandler, keep track of outstanding transactions and their OVERLAPPED objects, and on termination issue UsbDk_AbortPipe() to all end points and then GetOverlappedResult() on all the outstanding OVERLAPPED objects.
This doesn't solve the problem if the process is killed in a way that doesn't invoke the sighandler though.

@gwgill
Copy link
Author

gwgill commented Nov 10, 2023

It seems that kvojacheck's fix for #105 is a 90% fix for this problem. It seems to prevent the need for a system re-boot, but does sometimes require a device re-plug to recover, which is not ideal.

@gwgill gwgill closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants