Skip to content

Commit 3b4f7b9

Browse files
committed
pkcs11: Don't touch readers or inserted cards in C_Initialize in 2.20 mode
This significantly speeds up calling C_Initialize. Thanks to Nikos Mavrogiannopoulos for the tip.
1 parent c2b6a0d commit 3b4f7b9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/pkcs11/pkcs11-global.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,12 @@ CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
243243
if (sc_pkcs11_conf.plug_and_play) {
244244
create_slot(NULL);
245245
}
246-
/* Create slots for readers found on initialization */
247-
for (i=0; i<sc_ctx_get_reader_count(context); i++) {
248-
initialize_reader(sc_ctx_get_reader(context, i));
249-
}
250246

251-
/* Set initial event state on slots */
252-
for (i=0; i<list_size(&virtual_slots); i++) {
253-
sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
254-
slot->events = 0; /* Initially there are no events */
247+
/* Create slots for readers found on initialization, only if in 2.11 mode */
248+
if (!sc_pkcs11_conf.plug_and_play) {
249+
for (i=0; i<sc_ctx_get_reader_count(context); i++) {
250+
initialize_reader(sc_ctx_get_reader(context, i));
251+
}
255252
}
256253

257254
out:

0 commit comments

Comments
 (0)