fix(hotplug_libudev.c): validate existing reader works before discarding duplicates in HPAddDevice - #261
Conversation
…ing duplicates in HPAddDevice When suspending to RAM, existing libusb handles break. With LudovicRousseau/CCID#191, when they get retried, they now correctly report IFD_NO_SUCH_DEVICE. This will cause ifdwrapper.c to correctly trigger a hotplug. Now, we just need to make sure that the presence of the previous broken handle doesn't cause our new handle to get discarded. This is patch two of a two-patch series targeting both the CCID and PCSC repos. See: LudovicRousseau/CCID#191
|
This one is more substantial and more likely to be wrong than the other patch, so I'll keep this in draft until I've fully tested it, unless you're really confident this is correct. |
|
Never mind, I'm apparently not testing it, since that causes my system to want to rebuild everything from source again. I'm 70-80% confident this works as intended. |
|
Can you provide a pcscd trace as documented at https://ccid.apdu.fr/#support please? |
|
Sure. It's intermittent, so I can't get it to you right away, but as soon as it happens I'll get the log file to you. |
|
Or, it could happen almost immediately without a suspend?! Chances are this patch won't end up fixing my issue then since I had assumed this was a bug related to resume from suspend (since that's when it most often happens). I killed it with My javacard is currently inserted into the reader; removing and reinserting it does not fix the issue. Back when I was using a yubikey, removing and reinserting the yubikey also did not fix the issue. A restart of pcscd, even without removing and reinserting the key, would cause it to work correctly again. EDIT: Never mind, it turns out that that's a different problem presenting as a similar issue. I'll modify the systemd unit with those debugging flags; and I'll explain a bit more later. |
|
Since I'm on NixOS and it doesn't have Will get back to you when I repro it. |
|
i do not see any problem in you logs. But this: is not a good way to use USB devices. I think you need to use: |
|
Okay, I've finally hit it again. Here are the last 2k lines from the log. Can't upload the whole thing because it's over 25 MB and 192k lines long. |
|
Here's a complete log run for one that happened a lot faster. I now no longer think this is a resume from suspend-related bug, since I'm pretty sure I didn't step away during those 30 minutes. This patch is still probably correct, but I'm no longer confident this fixes my specific issue. |
|
Here's one that happened in ~10 minutes |
|
I do not find any error or issue in your latest log. What line in the log is problematic according to you? |
|
The smartcard was reported as not inserted despite being inserted. I did notice |
|
I can't do anything if the reader reports "card absent" but the card is present. The Alcor Micro AU9540 or AU9560 readers are not very good readers. This problem has nothing to do with suspend to RAM. |
|
Fair enough. I'll assume this is a hardware bug then. |
When suspending to RAM, existing libusb handles break. With LudovicRousseau/CCID#191, when they get retried, they now correctly report IFD_NO_SUCH_DEVICE. This will cause ifdwrapper.c to correctly trigger a hotplug. Now, we just need to make sure that the presence of the previous broken handle doesn't cause our new handle to get discarded.
This is patch two of a two-patch series targeting both the CCID and PCSC repos. See: LudovicRousseau/CCID#191