[Pcsclite-cvs-commit] r2767 - /trunk/PCSC/src/winscard.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Thu Jan 24 15:12:12 UTC 2008
Author: rousseau
Date: Thu Jan 24 15:12:11 2008
New Revision: 2767
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=2767
Log:
SCardConnect(), SCardReconnect(), SCardDisconnect(): replace
SYS_USleep(PCSCLITE_STATUS_POLL_RATE + 10) by SYS_MMapSynchronize()
calls to gain performances.
Thanks to Sean Wykes for the patch
Modified:
trunk/PCSC/src/winscard.c
Modified: trunk/PCSC/src/winscard.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard.c?rev=2767&op=diff
==============================================================================
--- trunk/PCSC/src/winscard.c (original)
+++ trunk/PCSC/src/winscard.c Thu Jan 24 15:12:11 2008
@@ -336,9 +336,6 @@
while (rContext->dwLockId != 0)
SYS_USleep(PCSCLITE_LOCK_POLL_RATE);
Log1(PCSC_LOG_INFO, "Lock released");
-
- /* Allow the status thread to convey information */
- SYS_USleep(PCSCLITE_STATUS_POLL_RATE + 10);
}
/* the reader has been removed while we were waiting */
@@ -496,9 +493,10 @@
}
/*
- * Allow the status thread to convey information
- */
- SYS_USleep(PCSCLITE_STATUS_POLL_RATE + 10);
+ * Propagate new state to Shared Memory
+ */
+ rContext->readerState->readerSharing = rContext->dwContexts;
+ SYS_MMapSynchronize((void *) rContext->readerState, SYS_GetPageSize() );
PROFILE_END
@@ -511,7 +509,6 @@
{
LONG rv;
PREADER_CONTEXT rContext = NULL;
- int do_sleep = 1;
Log1(PCSC_LOG_DEBUG, "Attempting reconnect to token.");
@@ -675,8 +672,6 @@
return SCARD_F_INTERNAL_ERROR;
break;
}
-
- do_sleep = 1;
}
else
if (dwInitialization == SCARD_LEAVE_CARD)
@@ -684,7 +679,6 @@
/*
* Do nothing
*/
- do_sleep = 0;
}
/*******************************************
@@ -795,10 +789,10 @@
RFClearReaderEventState(rContext, hCard);
/*
- * Allow the status thread to convey information
- */
- if (do_sleep)
- SYS_USleep(PCSCLITE_STATUS_POLL_RATE + 10);
+ * Propagate new state to Shared Memory
+ */
+ rContext->readerState->readerSharing = rContext->dwContexts;
+ SYS_MMapSynchronize((void *) rContext->readerState, SYS_GetPageSize() );
return SCARD_S_SUCCESS;
}
@@ -913,11 +907,6 @@
Log1(PCSC_LOG_DEBUG, "Reset complete.");
else
Log1(PCSC_LOG_ERROR, "Error resetting card.");
-
- /*
- * Allow the status thread to convey information
- */
- SYS_USleep(PCSCLITE_STATUS_POLL_RATE + 10);
}
else if (dwDisposition == SCARD_EJECT_CARD)
{
@@ -970,18 +959,23 @@
* For exclusive connection reset it to no connections
*/
if (rContext->dwContexts == SCARD_EXCLUSIVE_CONTEXT)
- {
rContext->dwContexts = SCARD_NO_CONTEXT;
- return SCARD_S_SUCCESS;
- }
-
- /*
- * Remove a connection from the context stack
- */
- rContext->dwContexts -= 1;
-
- if (rContext->dwContexts < 0)
- rContext->dwContexts = 0;
+ else
+ {
+ /*
+ * Remove a connection from the context stack
+ */
+ rContext->dwContexts -= 1;
+
+ if (rContext->dwContexts < 0)
+ rContext->dwContexts = 0;
+ }
+
+ /*
+ * Propagate new state to Shared Memory
+ */
+ rContext->readerState->readerSharing = rContext->dwContexts;
+ SYS_MMapSynchronize((void *) rContext->readerState, SYS_GetPageSize() );
return SCARD_S_SUCCESS;
}
More information about the Pcsclite-cvs-commit
mailing list