Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is follow-up work on the #1822, mostly based on my last comment #1822 (comment) which I will try to summarize here again with the steps that happens and causes the issue reported above
C_GetSlotInfo()card_detect_all()->card_detect()->sc_detect_card_presence()->pcsc_detect_card_presence()refresh_attributes()notices the card was changed (SCardStatusreturnsSCARD_E_INVALID_VALUEas handled in fb15a7d )CARD_CHANGEDcard_removed(), the reader->flags is reset (CARD_PRESENTis removed here)card_detect_all()->card_detect()->sc_detect_card_presence()->pcsc_detect_card_presence()refresh_attributes()notices returnsSCARD_E_TIMEOUTas there was really no change since last call.CARD_PRESENTin the reader flags so the card detection can finally startHere is the raw log of the affected part of the code:
The second commit bf4ef3f is addressing another issue that I noticed on the PKCS#11 level, when the first function after reinsertion was
C_GetSessionInfo(), the OpenSC sometimes wrongly reported invalid login status, confusing the calling application.Checklist