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

candleapi driver on win*: hang on CloseHandle() #16

Open
fenugrec opened this issue Jun 12, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@fenugrec
Copy link

commented Jun 12, 2019

I'm having trouble with the windows candleapi driver, which I'm trying to use for a personal project.

I reduced the test case to the following code:
https://gist.github.com/fenugrec/5322ba8ae2fb90f5c34dd435b1eade75

The essential part is simply "candle_dev_open()" followed by "candle_dev_close()".
When calling candle_dev_close(), the program hangs in the last CloseHandle() called with the device handle (right after WinUsb_Free()). If I force a device reset the call completes succesfully and the program exits cleanly.

If I modify candle_dev_open() to not prepare the URBs (i.e. disable candle_prepare_read() ), then CloseHandle() will work properly.

I'm not sure what's wrong with the URBs or associated events ?

Could be related to https://github.com/HubertD/candle_dll/pull/1/files#diff-6df29908f0b6ce54be11da5e7367e498R322 ?

@fenugrec

This comment has been minimized.

Copy link
Author

commented Jun 12, 2019

Hah ! Adding a call to "CancelIo(dev->deviceHandle);" inside candle_close_rxurbs() seems to fix the issue here. However, MSDN docs state

The function does not cancel I/O operations that other threads issue for a file handle.

To cancel I/O operations from another thread, use the CancelIoEx function.

But, CancelIoEx is not supported on winXP (I'm trying to keep compatibility in my application), so I'm not sure how reliable CancelIo will be on multi-threaded applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.