[Pcsclite-cvs-commit] r4514 - in /trunk/PCSC/src: winscard_clnt.c winscard_msg.c winscard_svc.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Oct 27 08:41:03 UTC 2009


Author: rousseau
Date: Tue Oct 27 08:41:03 2009
New Revision: 4514

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4514
Log:
SHMMessageReceive() now returns -2 in case of timeout and -1 in case of
other error

This is used to correctly handle timeouts in SCardGetStatusChange()

Modified:
    trunk/PCSC/src/winscard_clnt.c
    trunk/PCSC/src/winscard_msg.c
    trunk/PCSC/src/winscard_svc.c

Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=4514&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Oct 27 08:41:03 2009
@@ -444,8 +444,8 @@
 			return SCARD_E_NO_SERVICE;
 
 		/* Read a message from the server */
-		if (-1 == SHMMessageReceive(&veStr, sizeof(veStr), dwClientID,
-			PCSCLITE_READ_TIMEOUT))
+		if (SHMMessageReceive(&veStr, sizeof(veStr), dwClientID,
+			PCSCLITE_READ_TIMEOUT) < 0)
 		{
 			Log1(PCSC_LOG_CRITICAL, "Your pcscd is too old and does not support CMD_VERSION");
 			return SCARD_F_COMM_ERROR;
@@ -480,7 +480,7 @@
 	 */
 	rv = SHMMessageReceive(&scEstablishStruct, sizeof(scEstablishStruct), dwClientID, PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 		return SCARD_F_COMM_ERROR;
 
 	if (scEstablishStruct.rv != SCARD_S_SUCCESS)
@@ -586,7 +586,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -759,7 +759,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -912,7 +912,7 @@
 			psContextMap[dwContextIndex].dwClientID,
 			PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -1010,7 +1010,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -1118,7 +1118,7 @@
 			psContextMap[dwContextIndex].dwClientID,
 			PCSCLITE_READ_TIMEOUT);
 
-		if (rv == -1)
+		if (rv < 0)
 		{
 			rv = SCARD_F_COMM_ERROR;
 			goto end;
@@ -1233,7 +1233,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -1309,7 +1309,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -1513,7 +1513,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -1770,7 +1770,7 @@
 		rgReaderStates[j].dwEventState = 0;
 
 	/* Now is where we start our event checking loop */
-	Log1(PCSC_LOG_DEBUG, "Event Loop Start");
+	Log2(PCSC_LOG_DEBUG, "Event Loop Start, dwTimeout: %ld", dwTimeout);
 
 	/* Get the initial reader count on the system */
 	for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
@@ -2094,9 +2094,9 @@
 					dwTime);
 
 				/* timeout */
-				if (-1 == rv)
+				if (-2 == rv)
 				{
-					/* aask server to remove us from the event list */
+					/* ask server to remove us from the event list */
 					rv = SHMMessageSendWithHeader(CMD_STOP_WAITING_READER_STATE_CHANGE,
 						psContextMap[dwContextIndex].dwClientID,
 						sizeof(waitStatusStruct), PCSCLITE_WRITE_TIMEOUT,
@@ -2111,13 +2111,19 @@
 					/* Read a message from the server */
 					rv = SHMMessageReceive(&waitStatusStruct, sizeof(waitStatusStruct),
 						psContextMap[dwContextIndex].dwClientID,
-						dwTime);
+						PCSCLITE_READ_TIMEOUT);
 
 					if (rv == -1)
 					{
 						rv = SCARD_E_NO_SERVICE;
 						goto end;
 					}
+				}
+
+				if (rv < 0)
+				{
+					rv = SCARD_E_NO_SERVICE;
+					goto end;
 				}
 
 				/* an event occurs or SCardCancel() was called */
@@ -2295,7 +2301,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -2308,7 +2314,7 @@
 			psContextMap[dwContextIndex].dwClientID,
 			PCSCLITE_READ_TIMEOUT);
 
-		if (rv == -1)
+		if (rv < 0)
 		{
 			rv = SCARD_E_NO_SERVICE;
 			goto end;
@@ -2578,7 +2584,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -2760,7 +2766,7 @@
 		psContextMap[dwContextIndex].dwClientID,
 		PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -2773,7 +2779,7 @@
 			psContextMap[dwContextIndex].dwClientID,
 			PCSCLITE_READ_TIMEOUT);
 
-		if (rv == -1)
+		if (rv < 0)
 		{
 			rv = SCARD_E_NO_SERVICE;
 			goto end;
@@ -3189,7 +3195,7 @@
 	rv = SHMMessageReceive(&scCancelStruct, sizeof(scCancelStruct),
 		dwClientID, PCSCLITE_READ_TIMEOUT);
 
-	if (rv == -1)
+	if (rv < 0)
 	{
 		rv = SCARD_F_COMM_ERROR;
 		goto end;
@@ -3547,8 +3553,8 @@
 		return SCARD_E_NO_SERVICE;
 
 	/* Read a message from the server */
-	if (-1 == SHMMessageReceive(&readerStates, sizeof(readerStates), dwClientID,
-		PCSCLITE_READ_TIMEOUT))
+	if (SHMMessageReceive(&readerStates, sizeof(readerStates), dwClientID,
+		PCSCLITE_READ_TIMEOUT) < 0)
 		return SCARD_F_COMM_ERROR;
 
 	return SCARD_S_SUCCESS;

Modified: trunk/PCSC/src/winscard_msg.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_msg.c?rev=4514&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_msg.c (original)
+++ trunk/PCSC/src/winscard_msg.c Tue Oct 27 08:41:03 2009
@@ -277,7 +277,7 @@
 		if (delta > timeOut*1000)
 		{
 			/* we already timed out */
-			retval = -1;
+			retval = -2;
 			break;
 		}
 

Modified: trunk/PCSC/src/winscard_svc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_svc.c?rev=4514&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_svc.c (original)
+++ trunk/PCSC/src/winscard_svc.c Tue Oct 27 08:41:03 2009
@@ -119,7 +119,7 @@
 #define READ_BODY(v) \
 	if (header.size != sizeof(v)) {printf("%d %d\n", header.size, sizeof(v)); goto wrong_length;} \
 	ret = SHMMessageReceive(&v, sizeof(v), filedes, PCSCLITE_READ_TIMEOUT); \
-	if (-1 == ret) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }
+	if (ret < 0) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }
 
 #define WRITE_BODY(v) \
 	ret = SHMMessageSend(&v, sizeof(v), filedes, PCSCLITE_WRITE_TIMEOUT);
@@ -160,7 +160,7 @@
 #define READ_BODY(v) \
 	if (header.size != sizeof(v)) {printf("%d %d\n", header.size, sizeof(v)); goto wrong_length;} \
 	ret = SHMMessageReceive(&v, sizeof(v), filedes, PCSCLITE_READ_TIMEOUT); \
-	if (-1 == ret) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }
+	if (ret < 0) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }
 
 #define WRITE_BODY(v) \
 	ret = SHMMessageSend(&v, sizeof(v), filedes, PCSCLITE_WRITE_TIMEOUT);
@@ -178,7 +178,7 @@
 		struct rxHeader header;
 		int32_t ret = SHMMessageReceive(&header, sizeof(header), filedes, PCSCLITE_READ_TIMEOUT);
 
-		if (-1 == ret)
+		if (ret < 0)
 		{
 			/* Clean up the dead client */
 			Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes);
@@ -507,7 +507,7 @@
 				/* read sent buffer */
 				ret = SHMMessageReceive(pbSendBuffer, trStr.cbSendLength,
 					filedes, PCSCLITE_READ_TIMEOUT);
-				if (-1 == ret)
+				if (ret < 0)
 				{
 					Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes);
 					goto exit;
@@ -560,7 +560,7 @@
 				/* read sent buffer */
 				ret = SHMMessageReceive(pbSendBuffer, ctStr.cbSendLength,
 					filedes, PCSCLITE_READ_TIMEOUT);
-				if (-1 == ret)
+				if (ret < 0)
 				{
 					Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes);
 					goto exit;




More information about the Pcsclite-cvs-commit mailing list