[Pcsclite-cvs-commit] r6680 - trunk/PCSC/src
ludovic.rousseau at free.fr
ludovic.rousseau at free.fr
Sun Jul 28 09:30:21 UTC 2013
Author: rousseau
Date: 2013-07-01 08:34:26 +0000 (Mon, 01 Jul 2013)
New Revision: 6680
Modified:
trunk/PCSC/src/winscard_clnt.c
Log:
Do not use pthread_atfork() any more
pthread_atfork() was used to invalidate all the handles after a fork.
The problem is that the handler function was still called after the
libpcsclite library was unloaded on FreeBSD. This caused a crash of the
application.
The invalidation of the handles is not mandatory. After a fork the
application may still use the PC/SC handles and may get a
SCARD_F_COMM_ERROR error if the handle has been closed and in the pcscd logs:
winscard_svc.c:908:MSGCheckHandleAssociation() Client failed to authenticate
Closes Alioth bug [#314078] Do not use pthread_atfork() in a library
https://alioth.debian.org/tracker/index.php?func=detail&aid=314078&group_id=30105&atid=410085
Modified: trunk/PCSC/src/winscard_clnt.c
===================================================================
--- trunk/PCSC/src/winscard_clnt.c 2013-06-30 15:22:28 UTC (rev 6679)
+++ trunk/PCSC/src/winscard_clnt.c 2013-07-01 08:34:26 UTC (rev 6680)
@@ -353,7 +353,6 @@
/*@out@*/ SCONTEXTMAP * *, /*@out@*/ CHANNEL_MAP * *);
static LONG SCardRemoveHandle(SCARDHANDLE);
-static void SCardInvalidateHandles(void);
static LONG SCardGetSetAttrib(SCARDHANDLE hCard, int command, DWORD dwAttrId,
LPBYTE pbAttr, LPDWORD pcbAttrLen);
@@ -423,20 +422,10 @@
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
{
LONG rv;
- static int first_time = TRUE;
API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
PROFILE_START
- /* Some setup for the first execution */
- if (first_time)
- {
- first_time = FALSE;
-
- /* Invalidate all the handles in the son after a fork */
- pthread_atfork(NULL, NULL, SCardInvalidateHandles);
- }
-
/* Check if the server is running */
rv = SCardCheckDaemonAvailability();
if (SCARD_E_INVALID_HANDLE == rv)
@@ -3623,25 +3612,6 @@
return SCARD_S_SUCCESS;
}
-static void SCardInvalidateHandles(void)
-{
- /* invalid all handles */
- (void)SCardLockThread();
-
- while (list_size(&contextMapList) != 0)
- {
- SCONTEXTMAP * currentContextMap;
-
- currentContextMap = list_get_at(&contextMapList, 0);
- if (currentContextMap != NULL)
- (void)SCardCleanContext(currentContextMap);
- else
- Log1(PCSC_LOG_CRITICAL, "list_get_at returned NULL");
- }
-
- (void)SCardUnlockThread();
-}
-
static LONG getReaderStates(SCONTEXTMAP * currentContextMap)
{
int32_t dwClientID = currentContextMap->dwClientID;
More information about the Pcsclite-cvs-commit
mailing list