[Pcsclite-cvs-commit] r4952 - in /trunk/PCSC/src: pcscd.h.in winscard_clnt.c winscard_msg.c winscard_msg.h winscard_svc.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue May 18 13:42:44 UTC 2010
Author: rousseau
Date: Tue May 18 13:42:25 2010
New Revision: 4952
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4952
Log:
MessageSend(), MessageReceive() & MessageSendWithHeader() do not timeout
any more. If the other side of the socket dies we will get an error from
the kernel.
Add a new MessageReceiveTimeout() to implement SCardGetStatusChange()
with a timeout.
The constants PCSCLITE_WRITE_TIMEOUT & PCSCLITE_READ_TIMEOUT are now
also removed.
The problem was that if a client does nothing during
PCSCLITE_READ_TIMEOUT (120 seconds by default) then pcscd considers it
as a dead client and closes the connection. I guess this problem was
present since the first version of pcsc-lite but nobody complained
before.
Thanks to Thierry Fabre for the bug report.
Modified:
trunk/PCSC/src/pcscd.h.in
trunk/PCSC/src/winscard_clnt.c
trunk/PCSC/src/winscard_msg.c
trunk/PCSC/src/winscard_msg.h
trunk/PCSC/src/winscard_svc.c
Modified: trunk/PCSC/src/pcscd.h.in
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscd.h.in?rev=4952&op=diff
==============================================================================
--- trunk/PCSC/src/pcscd.h.in (original)
+++ trunk/PCSC/src/pcscd.h.in Tue May 18 13:42:25 2010
@@ -34,8 +34,6 @@
#define PCSCLITE_SVC_IDENTITY 0x01030000 /**< Service ID */
#define PCSCLITE_VERSION_NUMBER "@VERSION@" /**< Current version */
-#define PCSCLITE_WRITE_TIMEOUT 1000 /**< write timeout */
-#define PCSCLITE_READ_TIMEOUT 120*1000 /**< read timeout */
#define PCSCLITE_STATUS_POLL_RATE 400000 /**< Status polling rate */
#define PCSCLITE_LOCK_POLL_RATE 100000 /**< Lock polling rate */
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=4952&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue May 18 13:42:25 2010
@@ -568,12 +568,11 @@
veStr.rv = SCARD_S_SUCCESS;
if (-1 == MessageSendWithHeader(CMD_VERSION, dwClientID, sizeof(veStr),
- PCSCLITE_WRITE_TIMEOUT, &veStr))
+ &veStr))
return SCARD_E_NO_SERVICE;
/* Read a message from the server */
- if (MessageReceive(CMD_VERSION, &veStr, sizeof(veStr), dwClientID,
- PCSCLITE_READ_TIMEOUT) < 0)
+ if (MessageReceive(&veStr, sizeof(veStr), dwClientID) < 0)
{
Log1(PCSC_LOG_CRITICAL, "Your pcscd is too old and does not support CMD_VERSION");
return SCARD_F_COMM_ERROR;
@@ -595,8 +594,7 @@
scEstablishStruct.rv = SCARD_S_SUCCESS;
rv = MessageSendWithHeader(SCARD_ESTABLISH_CONTEXT, dwClientID,
- sizeof(scEstablishStruct), PCSCLITE_WRITE_TIMEOUT,
- (void *) &scEstablishStruct);
+ sizeof(scEstablishStruct), (void *) &scEstablishStruct);
if (rv == -1)
return SCARD_E_NO_SERVICE;
@@ -604,7 +602,7 @@
/*
* Read the response from the server
*/
- rv = MessageReceive(SCARD_ESTABLISH_CONTEXT, &scEstablishStruct, sizeof(scEstablishStruct), dwClientID, PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scEstablishStruct, sizeof(scEstablishStruct), dwClientID);
if (rv < 0)
return SCARD_F_COMM_ERROR;
@@ -686,7 +684,7 @@
rv = MessageSendWithHeader(SCARD_RELEASE_CONTEXT,
currentContextMap->dwClientID,
sizeof(scReleaseStruct),
- PCSCLITE_WRITE_TIMEOUT, (void *) &scReleaseStruct);
+ (void *) &scReleaseStruct);
if (rv == -1)
{
@@ -697,9 +695,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_RELEASE_CONTEXT, &scReleaseStruct, sizeof(scReleaseStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scReleaseStruct, sizeof(scReleaseStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -863,7 +860,7 @@
rv = MessageSendWithHeader(SCARD_CONNECT, currentContextMap->dwClientID,
sizeof(scConnectStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scConnectStruct);
+ (void *) &scConnectStruct);
if (rv == -1)
{
@@ -874,9 +871,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_CONNECT, &scConnectStruct, sizeof(scConnectStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scConnectStruct, sizeof(scConnectStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1026,7 +1022,7 @@
rv = MessageSendWithHeader(SCARD_RECONNECT,
currentContextMap->dwClientID,
sizeof(scReconnectStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scReconnectStruct);
+ (void *) &scReconnectStruct);
if (rv == -1)
{
@@ -1037,10 +1033,9 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_RECONNECT, &scReconnectStruct,
+ rv = MessageReceive(&scReconnectStruct,
sizeof(scReconnectStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1134,7 +1129,7 @@
rv = MessageSendWithHeader(SCARD_DISCONNECT,
currentContextMap->dwClientID,
sizeof(scDisconnectStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scDisconnectStruct);
+ (void *) &scDisconnectStruct);
if (rv == -1)
{
@@ -1145,10 +1140,9 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_DISCONNECT, &scDisconnectStruct,
+ rv = MessageReceive(&scDisconnectStruct,
sizeof(scDisconnectStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1246,7 +1240,7 @@
rv = MessageSendWithHeader(SCARD_BEGIN_TRANSACTION,
currentContextMap->dwClientID,
sizeof(scBeginStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scBeginStruct);
+ (void *) &scBeginStruct);
if (rv == -1)
{
@@ -1257,9 +1251,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_BEGIN_TRANSACTION, &scBeginStruct, sizeof(scBeginStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scBeginStruct, sizeof(scBeginStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1362,7 +1355,7 @@
rv = MessageSendWithHeader(SCARD_END_TRANSACTION,
currentContextMap->dwClientID,
sizeof(scEndStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scEndStruct);
+ (void *) &scEndStruct);
if (rv == -1)
{
@@ -1373,9 +1366,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_END_TRANSACTION, &scEndStruct, sizeof(scEndStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scEndStruct, sizeof(scEndStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1438,8 +1430,7 @@
rv = MessageSendWithHeader(SCARD_CANCEL_TRANSACTION,
currentContextMap->dwClientID,
- sizeof(scCancelStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scCancelStruct);
+ sizeof(scCancelStruct), (void *) &scCancelStruct);
if (rv == -1)
{
@@ -1450,9 +1441,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_CANCEL_TRANSACTION, &scCancelStruct, sizeof(scCancelStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scCancelStruct, sizeof(scCancelStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -1649,7 +1639,7 @@
rv = MessageSendWithHeader(SCARD_STATUS, currentContextMap->dwClientID,
sizeof(scStatusStruct),
- PCSCLITE_READ_TIMEOUT, (void *) &scStatusStruct);
+ (void *) &scStatusStruct);
if (rv == -1)
{
@@ -1660,9 +1650,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_STATUS, &scStatusStruct, sizeof(scStatusStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scStatusStruct, sizeof(scStatusStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -2226,7 +2215,7 @@
rv = MessageSendWithHeader(CMD_WAIT_READER_STATE_CHANGE,
currentContextMap->dwClientID,
- sizeof(waitStatusStruct), PCSCLITE_WRITE_TIMEOUT,
+ sizeof(waitStatusStruct),
&waitStatusStruct);
if (rv == -1)
@@ -2238,9 +2227,9 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(CMD_WAIT_READER_STATE_CHANGE, &waitStatusStruct, sizeof(waitStatusStruct),
- currentContextMap->dwClientID,
- dwTime);
+ rv = MessageReceiveTimeout(CMD_WAIT_READER_STATE_CHANGE,
+ &waitStatusStruct, sizeof(waitStatusStruct),
+ currentContextMap->dwClientID, dwTime);
/* timeout */
if (-2 == rv)
@@ -2248,7 +2237,7 @@
/* ask server to remove us from the event list */
rv = MessageSendWithHeader(CMD_STOP_WAITING_READER_STATE_CHANGE,
currentContextMap->dwClientID,
- sizeof(waitStatusStruct), PCSCLITE_WRITE_TIMEOUT,
+ sizeof(waitStatusStruct),
&waitStatusStruct);
if (rv == -1)
@@ -2258,9 +2247,9 @@
}
/* Read a message from the server */
- rv = MessageReceive(CMD_STOP_WAITING_READER_STATE_CHANGE, &waitStatusStruct, sizeof(waitStatusStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&waitStatusStruct,
+ sizeof(waitStatusStruct),
+ currentContextMap->dwClientID);
if (rv == -1)
{
@@ -2428,7 +2417,7 @@
rv = MessageSendWithHeader(SCARD_CONTROL,
currentContextMap->dwClientID,
- sizeof(scControlStruct), PCSCLITE_READ_TIMEOUT, &scControlStruct);
+ sizeof(scControlStruct), &scControlStruct);
if (rv == -1)
{
@@ -2438,7 +2427,7 @@
/* write the sent buffer */
rv = MessageSend((char *)pbSendBuffer, cbSendLength,
- currentContextMap->dwClientID, PCSCLITE_WRITE_TIMEOUT);
+ currentContextMap->dwClientID);
if (rv == -1)
{
@@ -2449,9 +2438,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_CONTROL, &scControlStruct, sizeof(scControlStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scControlStruct, sizeof(scControlStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -2462,9 +2450,8 @@
if (SCARD_S_SUCCESS == scControlStruct.rv)
{
/* read the received buffer */
- rv = MessageReceive(SCARD_CONTROL, pbRecvBuffer, scControlStruct.dwBytesReturned,
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(pbRecvBuffer, scControlStruct.dwBytesReturned,
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -2730,7 +2717,7 @@
rv = MessageSendWithHeader(command,
currentContextMap->dwClientID, sizeof(scGetSetStruct),
- PCSCLITE_READ_TIMEOUT, &scGetSetStruct);
+ &scGetSetStruct);
if (rv == -1)
{
@@ -2741,9 +2728,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(command, &scGetSetStruct, sizeof(scGetSetStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scGetSetStruct, sizeof(scGetSetStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -2906,7 +2892,7 @@
rv = MessageSendWithHeader(SCARD_TRANSMIT,
currentContextMap->dwClientID, sizeof(scTransmitStruct),
- PCSCLITE_WRITE_TIMEOUT, (void *) &scTransmitStruct);
+ (void *) &scTransmitStruct);
if (rv == -1)
{
@@ -2916,7 +2902,7 @@
/* write the sent buffer */
rv = MessageSend((void *)pbSendBuffer, cbSendLength,
- currentContextMap->dwClientID, PCSCLITE_WRITE_TIMEOUT);
+ currentContextMap->dwClientID);
if (rv == -1)
{
@@ -2927,9 +2913,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_TRANSMIT, &scTransmitStruct, sizeof(scTransmitStruct),
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scTransmitStruct, sizeof(scTransmitStruct),
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -2940,9 +2925,8 @@
if (SCARD_S_SUCCESS == scTransmitStruct.rv)
{
/* read the received buffer */
- rv = MessageReceive(SCARD_TRANSMIT, pbRecvBuffer, scTransmitStruct.pcbRecvLength,
- currentContextMap->dwClientID,
- PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(pbRecvBuffer, scTransmitStruct.pcbRecvLength,
+ currentContextMap->dwClientID);
if (rv < 0)
{
@@ -3353,8 +3337,7 @@
rv = MessageSendWithHeader(SCARD_CANCEL,
dwClientID,
- sizeof(scCancelStruct), PCSCLITE_READ_TIMEOUT, (void *)
- &scCancelStruct);
+ sizeof(scCancelStruct), (void *) &scCancelStruct);
if (rv == -1)
{
@@ -3365,8 +3348,8 @@
/*
* Read a message from the server
*/
- rv = MessageReceive(SCARD_CANCEL, &scCancelStruct, sizeof(scCancelStruct),
- dwClientID, PCSCLITE_READ_TIMEOUT);
+ rv = MessageReceive(&scCancelStruct, sizeof(scCancelStruct),
+ dwClientID);
if (rv < 0)
{
@@ -3817,13 +3800,11 @@
{
int32_t dwClientID = currentContextMap->dwClientID;
- if (-1 == MessageSendWithHeader(CMD_GET_READERS_STATE, dwClientID, 0,
- PCSCLITE_WRITE_TIMEOUT, NULL))
+ if (-1 == MessageSendWithHeader(CMD_GET_READERS_STATE, dwClientID, 0, NULL))
return SCARD_E_NO_SERVICE;
/* Read a message from the server */
- if (MessageReceive(CMD_GET_READERS_STATE, &readerStates, sizeof(readerStates), dwClientID,
- PCSCLITE_READ_TIMEOUT) < 0)
+ if (MessageReceive(&readerStates, sizeof(readerStates), dwClientID) < 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=4952&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_msg.c (original)
+++ trunk/PCSC/src/winscard_msg.c Tue May 18 13:42:25 2010
@@ -126,49 +126,26 @@
* @retval -1 A signal was received.
*/
INTERNAL int32_t MessageSend(void *buffer_void, uint64_t buffer_size,
- int32_t filedes, int32_t timeOut)
+ int32_t filedes)
{
char *buffer = buffer_void;
/* default is success */
int retval = 0;
- /* record the time when we started */
- struct timeval start;
-
/* how many bytes remains to be written */
size_t remaining = buffer_size;
- gettimeofday(&start, NULL);
-
/* repeat until all data is written */
while (remaining > 0)
{
fd_set write_fd;
- struct timeval timeout, now;
int selret;
- long delta;
-
- gettimeofday(&now, NULL);
- delta = time_sub(&now, &start);
-
- if (delta > timeOut*1000)
- {
- /* we already timed out */
- retval = -1;
- break;
- }
-
- /* remaining time to wait */
- delta = timeOut*1000 - delta;
FD_ZERO(&write_fd);
FD_SET(filedes, &write_fd);
- timeout.tv_sec = delta/1000000;
- timeout.tv_usec = delta - timeout.tv_sec*1000000;
-
- selret = select(filedes + 1, NULL, &write_fd, NULL, &timeout);
+ selret = select(filedes + 1, NULL, &write_fd, NULL, NULL);
/* try to write only when the file descriptor is writable */
if (selret > 0)
@@ -238,61 +215,35 @@
*
* Reads the message from the file \c filedes.
*
- * @param[in] command one of the \ref pcsc_msg_commands commands
* @param[out] buffer_void Message read.
* @param[in] buffer_size Size to read
* @param[in] filedes Socket handle.
- * @param[in] timeOut Timeout in milliseconds.
*
* @retval 0 Success.
- * @retval -1 Timeout.
* @retval -1 Socket is closed.
* @retval -1 A signal was received.
*/
-INTERNAL int32_t MessageReceive(uint32_t command, void *buffer_void,
- uint64_t buffer_size, int32_t filedes, int32_t timeOut)
+INTERNAL int32_t MessageReceive(void *buffer_void, uint64_t buffer_size,
+ int32_t filedes)
{
char *buffer = buffer_void;
/* default is success */
int retval = 0;
- /* record the time when we started */
- struct timeval start;
-
/* how many bytes we must read */
size_t remaining = buffer_size;
- gettimeofday(&start, NULL);
-
/* repeat until we get the whole message */
while (remaining > 0)
{
fd_set read_fd;
- struct timeval timeout, now;
int selret;
- long delta;
-
- gettimeofday(&now, NULL);
- delta = time_sub(&now, &start);
-
- if (delta > timeOut*1000)
- {
- /* we already timed out */
- retval = -2;
- break;
- }
-
- /* remaining time to wait */
- delta = timeOut*1000 - delta;
FD_ZERO(&read_fd);
FD_SET(filedes, &read_fd);
- timeout.tv_sec = delta/1000000;
- timeout.tv_usec = delta - timeout.tv_sec*1000000;
-
- selret = select(filedes + 1, &read_fd, NULL, NULL, &timeout);
+ selret = select(filedes + 1, &read_fd, NULL, NULL, NULL);
/* try to read only when socket is readable */
if (selret > 0)
@@ -327,6 +278,117 @@
break;
}
}
+ }
+ else
+ {
+ /* we ignore signals, all other errors are fatal */
+ if (errno != EINTR)
+ {
+ Log2(PCSC_LOG_ERROR, "select returns with failure: %s",
+ strerror(errno));
+ retval = -1;
+ break;
+ }
+ }
+ }
+
+ return retval;
+}
+
+/**
+ * @brief Called by the Client to get the reponse from the server or vice-versa.
+ *
+ * Reads the message from the file \c filedes.
+ *
+ * @param[in] command one of the \ref pcsc_msg_commands commands
+ * @param[out] buffer_void Message read.
+ * @param[in] buffer_size Size to read
+ * @param[in] filedes Socket handle.
+ * @param[in] timeOut Timeout in milliseconds.
+ *
+ * @retval 0 Success.
+ * @retval -1 Timeout.
+ * @retval -1 Socket is closed.
+ * @retval -1 A signal was received.
+ */
+INTERNAL int32_t MessageReceiveTimeout(uint32_t command, void *buffer_void,
+ uint64_t buffer_size, int32_t filedes, int32_t timeOut)
+{
+ char *buffer = buffer_void;
+
+ /* default is success */
+ int retval = 0;
+
+ /* record the time when we started */
+ struct timeval start;
+
+ /* how many bytes we must read */
+ size_t remaining = buffer_size;
+
+ gettimeofday(&start, NULL);
+
+ /* repeat until we get the whole message */
+ while (remaining > 0)
+ {
+ fd_set read_fd;
+ struct timeval timeout, now;
+ int selret;
+ long delta;
+
+ gettimeofday(&now, NULL);
+ delta = time_sub(&now, &start);
+
+ if (delta > timeOut*1000)
+ {
+ /* we already timed out */
+ retval = -2;
+ break;
+ }
+
+ /* remaining time to wait */
+ delta = timeOut*1000 - delta;
+
+ FD_ZERO(&read_fd);
+ FD_SET(filedes, &read_fd);
+
+ timeout.tv_sec = delta/1000000;
+ timeout.tv_usec = delta - timeout.tv_sec*1000000;
+
+ selret = select(filedes + 1, &read_fd, NULL, NULL, &timeout);
+
+ /* try to read only when socket is readable */
+ if (selret > 0)
+ {
+ int readed;
+
+ if (!FD_ISSET(filedes, &read_fd))
+ {
+ /* very strange situation. it should be an assert really */
+ retval = -1;
+ break;
+ }
+ readed = read(filedes, buffer, remaining);
+
+ if (readed > 0)
+ {
+ /* we got something */
+ buffer += readed;
+ remaining -= readed;
+ } else if (readed == 0)
+ {
+ /* peer closed the socket */
+ retval = -1;
+ break;
+ } else
+ {
+ /* we ignore the signals and empty socket situations, all
+ * other errors are fatal */
+ if (errno != EINTR && errno != EAGAIN)
+ {
+ retval = -1;
+ break;
+ }
+ }
} else if (selret == 0)
{
#ifdef PCSCD
@@ -381,7 +443,7 @@
* @return Same error codes as MessageSend().
*/
INTERNAL int32_t MessageSendWithHeader(uint32_t command, uint32_t dwClientID,
- uint64_t size, uint32_t timeOut, void *data_void)
+ uint64_t size, void *data_void)
{
struct rxHeader header;
int ret;
@@ -389,10 +451,10 @@
/* header */
header.command = command;
header.size = size;
- ret = MessageSend(&header, sizeof(header), dwClientID, timeOut);
+ ret = MessageSend(&header, sizeof(header), dwClientID);
/* command */
- ret = MessageSend(data_void, size, dwClientID, timeOut);
+ ret = MessageSend(data_void, size, dwClientID);
return ret;
}
Modified: trunk/PCSC/src/winscard_msg.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_msg.h?rev=4952&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_msg.h (original)
+++ trunk/PCSC/src/winscard_msg.h Tue May 18 13:42:25 2010
@@ -274,12 +274,12 @@
int32_t ClientCloseSession(uint32_t);
int32_t InitializeSocket(void);
int32_t ProcessEventsServer(/*@out@*/ uint32_t *);
- int32_t MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes,
- int32_t blockAmount);
- int32_t MessageReceive(uint32_t command, /*@out@*/ void *buffer,
- uint64_t buffer_size, int32_t filedes, int32_t blockAmount);
- int32_t MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size,
- uint32_t blockAmount, void *data);
+ int32_t MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes);
+ int32_t MessageReceive(/*@out@*/ void *buffer, uint64_t buffer_size,
+ int32_t filedes);
+ int32_t MessageReceiveTimeout(uint32_t command, /*@out@*/ void *buffer,
+ uint64_t buffer_size, int32_t filedes, int32_t timeOut);
+ int32_t MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size, void *data);
void CleanupSharedSegment(int32_t, const char *);
#ifdef __cplusplus
Modified: trunk/PCSC/src/winscard_svc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_svc.c?rev=4952&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_svc.c (original)
+++ trunk/PCSC/src/winscard_svc.c Tue May 18 13:42:25 2010
@@ -273,14 +273,14 @@
#define READ_BODY(v) \
if (header.size != sizeof(v)) { goto wrong_length; } \
- ret = MessageReceive(header.command, &v, sizeof(v), filedes, PCSCLITE_READ_TIMEOUT); \
+ ret = MessageReceive(&v, sizeof(v), filedes); \
if (ret < 0) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }
#define WRITE_BODY(v) \
WRITE_BODY_WITH_COMMAND(CommandsText[header.command], v)
#define WRITE_BODY_WITH_COMMAND(command, v) \
Log4(SCARD_S_SUCCESS == v.rv ? PCSC_LOG_DEBUG : PCSC_LOG_ERROR, "%s rv=0x%X for client %d", command, v.rv, filedes); \
- ret = MessageSend(&v, sizeof(v), filedes, PCSCLITE_WRITE_TIMEOUT);
+ ret = MessageSend(&v, sizeof(v), filedes);
static void ContextThread(LPVOID newContext)
{
@@ -293,7 +293,7 @@
while (1)
{
struct rxHeader header;
- int32_t ret = MessageReceive(0, &header, sizeof(header), filedes, PCSCLITE_READ_TIMEOUT);
+ int32_t ret = MessageReceive(&header, sizeof(header), filedes);
if (ret < 0)
{
@@ -353,7 +353,7 @@
/* nothing to read */
/* dump the readers state */
- ret = MessageSend(readerStates, sizeof(readerStates), filedes, PCSCLITE_WRITE_TIMEOUT);
+ ret = MessageSend(readerStates, sizeof(readerStates), filedes);
}
break;
@@ -619,8 +619,7 @@
goto exit;
/* read sent buffer */
- ret = MessageReceive(SCARD_TRANSMIT, pbSendBuffer, trStr.cbSendLength,
- filedes, PCSCLITE_READ_TIMEOUT);
+ ret = MessageReceive(pbSendBuffer, trStr.cbSendLength, filedes);
if (ret < 0)
{
Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes);
@@ -647,8 +646,7 @@
/* write received buffer */
if (SCARD_S_SUCCESS == trStr.rv)
- ret = MessageSend(pbRecvBuffer, cbRecvLength,
- filedes, PCSCLITE_WRITE_TIMEOUT);
+ ret = MessageSend(pbRecvBuffer, cbRecvLength, filedes);
}
break;
@@ -672,8 +670,7 @@
}
/* read sent buffer */
- ret = MessageReceive(SCARD_CONTROL, pbSendBuffer, ctStr.cbSendLength,
- filedes, PCSCLITE_READ_TIMEOUT);
+ ret = MessageReceive(pbSendBuffer, ctStr.cbSendLength, filedes);
if (ret < 0)
{
Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes);
@@ -693,8 +690,7 @@
/* write received buffer */
if (SCARD_S_SUCCESS == ctStr.rv)
- ret = MessageSend(pbRecvBuffer, dwBytesReturned,
- filedes, PCSCLITE_WRITE_TIMEOUT);
+ ret = MessageSend(pbRecvBuffer, dwBytesReturned, filedes);
}
break;
More information about the Pcsclite-cvs-commit
mailing list