[Pcsclite-cvs-commit] r4938 - /trunk/Drivers/ccid/src/ifdhandler.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Mon May 10 09:42:35 UTC 2010
Author: rousseau
Date: Mon May 10 09:42:33 2010
New Revision: 4938
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4938
Log:
IFDHCreateChannelByName() & IFDHCreateChannel(): use the low level
CmdGetSlotStatus() instead of IFDHICCPresence() to be able to fix the
read timeout.
We use a read timeout of 100 milliseconds instead of 2 secondes. The
maximum wait time is now 200 milliseconds instead of 4 seconds.
This increases the startup time a lot (up to 95%) when pcscd is auto started.
Modified:
trunk/Drivers/ccid/src/ifdhandler.c
Modified: trunk/Drivers/ccid/src/ifdhandler.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ifdhandler.c?rev=4938&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ifdhandler.c (original)
+++ trunk/Drivers/ccid/src/ifdhandler.c Mon May 10 09:42:33 2010
@@ -112,17 +112,27 @@
}
else
{
+ unsigned char pcbuffer[SIZE_GET_SLOT_STATUS];
+ unsigned int oldReadTimeout;
+ _ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
+
/* Maybe we have a special treatment for this reader */
(void)ccid_open_hack_pre(reader_index);
+
+ /* save the current read timeout computed from card capabilities */
+ oldReadTimeout = ccid_descriptor->readTimeout;
+
+ /* 100ms just to resync the USB toggle bits */
+ ccid_descriptor->readTimeout = 100;
/* Try to access the reader */
/* This "warm up" sequence is sometimes needed when pcscd is
* restarted with the reader already connected. We get some
* "usb_bulk_read: Resource temporarily unavailable" on the first
* few tries. It is an empirical hack */
- if ((IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun))
- && (IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun))
- && (IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun)))
+ if ((IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer))
+ && (IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer))
+ && (IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer)))
{
DEBUG_CRITICAL("failed");
return_value = IFD_COMMUNICATION_ERROR;
@@ -132,8 +142,13 @@
ReleaseReaderIndex(reader_index);
}
else
+ {
+ /* set back the old timeout */
+ ccid_descriptor->readTimeout = oldReadTimeout;
+
/* Maybe we have a special treatment for this reader */
(void)ccid_open_hack_post(reader_index);
+ }
}
#ifdef HAVE_PTHREAD
@@ -214,17 +229,27 @@
}
else
{
+ unsigned char pcbuffer[SIZE_GET_SLOT_STATUS];
+ unsigned int oldReadTimeout;
+ _ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
+
/* Maybe we have a special treatment for this reader */
(void)ccid_open_hack_pre(reader_index);
+
+ /* save the current read timeout computed from card capabilities */
+ oldReadTimeout = ccid_descriptor->readTimeout;
+
+ /* 100ms just to resync the USB toggle bits */
+ ccid_descriptor->readTimeout = 100;
/* Try to access the reader */
/* This "warm up" sequence is sometimes needed when pcscd is
* restarted with the reader already connected. We get some
* "usb_bulk_read: Resource temporarily unavailable" on the first
* few tries. It is an empirical hack */
- if ((IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun))
- && (IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun))
- && (IFD_COMMUNICATION_ERROR == IFDHICCPresence(Lun)))
+ if ((IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer))
+ && (IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer))
+ && (IFD_COMMUNICATION_ERROR == CmdGetSlotStatus(reader_index, pcbuffer)))
{
DEBUG_CRITICAL("failed");
return_value = IFD_COMMUNICATION_ERROR;
@@ -234,8 +259,13 @@
ReleaseReaderIndex(reader_index);
}
else
+ {
+ /* set back the old timeout */
+ ccid_descriptor->readTimeout = oldReadTimeout;
+
/* Maybe we have a special treatment for this reader */
(void)ccid_open_hack_post(reader_index);
+ }
}
#ifdef HAVE_PTHREAD
More information about the Pcsclite-cvs-commit
mailing list