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

Fix polling transfer restart after InterruptStop #119

Conversation

emaxx-google
Copy link
Contributor

Fix the regression introduced in the "Fix InterruptStop if called before InterruptRead" commit: it should be possible to start a new polling transfer after the previous one has been stopped.

This problem prevented the polling transfer from working after an SCardDisconnect call, and led to using the sleep-based polling every 400 ms.

Implementation-wise, the fix is to change the "terminate" flag to be non-sticky, i.e., unset it after reading from it.

Fix the regression introduced in the "Fix InterruptStop if called
before InterruptRead" commit: it should be possible to start a new
polling transfer after the previous one has been stopped.

This problem prevented the polling transfer from working after an
SCardDisconnect call, and led to using the sleep-based polling every
400 ms.

Implementation-wise, the fix is to change the "terminate" flag to be
non-sticky, i.e., unset it after reading from it.
@@ -1622,6 +1617,10 @@ void InterruptStop(int reader_index)
if (ret < 0)
DEBUG_CRITICAL2("libusb_cancel_transfer failed: %s",
libusb_error_name(ret));
} else {
// Indicate that the next attempt to start an interrupt transfer shouldn't
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The potential problem is whether it's possible that InterruptStop() is called after the corresponding InterruptRead() already exited; in that case we'll incorrectly abort the next polling transfer later.

If that's possible indeed, I'm not 100% sure what should be the proper fix.

@LudovicRousseau LudovicRousseau merged commit f5a731e into LudovicRousseau:master Oct 29, 2023
9 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants