-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
ccid_usb: Use CLOCK_MONOTONIC for timeouts #138
ccid_usb: Use CLOCK_MONOTONIC for timeouts #138
Conversation
The pthread API unfortunately expects an absolute timestamp and not a duration value. With CLOCK_REALTIME changes to the system clock can result in timeouts happening earlier than expected, so use CLOCK_MONOTONIC instead.
I'm not sure if
|
Just curious:
|
It's happening on an embedded system we develop a custom Linux distro for, the issues was initially noticed when the card was in use while something else changed the clock. Very hard to reproduce, it depends on the timing, usually the system clock does not change that much. But it happened a few times during integration tests and only since 1.5.0. Syslog had this:
Got it down to the following one line reproducer:
Very much always errors out without the patch, can't trigger it with the patch anymore. |
Interesting. Can you reproduce the problem and generate a full pcscd log as documented at https://ccid.apdu.fr/#support ? |
The problem is the clock jumping forwards, which cuts the actual timeout short. Notice how my one liner jumps 1h ahead. This is really just a "
I can look into it when i find the time. I want to add this isn't an unknown issue all in all,
See libusb/libusb@ccba488 for the rational. |
I am not able to reproduce the problem on a Debian GNU/Linux system. What multi-slot reader do you use? |
Of course it doesn't work if you go into the past, I already explained you have to jump forward. The And it very much comes back with a timeout. Considers this simple example:
It's a very simple example that waits in Compile
and The first call will use I'm on Ubuntu 22.04, looks like this for me:
it just waits, and
errors out immediately.
It doesn't matter, it should be an issue with every multi-slot reader, because it's really just a POSIX API caveat. You have to change the time while waiting in the |
I know the problem is generic and not related to one specific reader. I guess your reader is NOT in this list. Right? |
The pthread API unfortunately expects an absolute timestamp and not a duration value. With CLOCK_REALTIME changes to the system clock can result in timeouts happening earlier than expected, so use CLOCK_MONOTONIC instead.