[Pcsclite-cvs-commit] r5102 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Aug 3 09:34:45 UTC 2010
Author: rousseau
Date: Tue Aug 3 09:34:41 2010
New Revision: 5102
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5102
Log:
Remove client side profiling since we can use ltrace(1) with better
results
Modified:
trunk/PCSC/src/winscard_clnt.c
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=5102&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Aug 3 09:34:41 2010
@@ -110,95 +110,6 @@
static char sharing_shall_block = TRUE;
-#undef DO_PROFILE
-#ifdef DO_PROFILE
-
-#define PROFILE_FILE "/tmp/pcsc_profile"
-#include <stdio.h>
-#include <sys/time.h>
-
-struct timeval profile_time_start;
-FILE *profile_fd;
-char profile_tty;
-char fct_name[100];
-
-#define PROFILE_START profile_start(__FUNCTION__);
-#define PROFILE_END(rv) profile_end(__FUNCTION__, rv);
-
-static void profile_start(const char *f)
-{
- static char initialized = FALSE;
-
- if (!initialized)
- {
- char filename[80];
-
- initialized = TRUE;
- sprintf(filename, "%s-%d", PROFILE_FILE, getuid());
- profile_fd = fopen(filename, "a+");
- if (NULL == profile_fd)
- {
- fprintf(stderr, "\33[01;31mCan't open %s: %s\33[0m\n",
- PROFILE_FILE, strerror(errno));
- exit(-1);
- }
- fprintf(profile_fd, "\nStart a new profile\n");
-
- if (isatty(fileno(stderr)))
- profile_tty = TRUE;
- else
- profile_tty = FALSE;
- }
-
- /* PROFILE_END was not called before? */
- if (profile_tty && fct_name[0])
- printf("\33[01;34m WARNING: %s starts before %s finishes\33[0m\n",
- f, fct_name);
-
- strlcpy(fct_name, f, sizeof(fct_name));
-
- gettimeofday(&profile_time_start, NULL);
-} /* profile_start */
-
-static void profile_end(const char *f, LONG rv)
-{
- struct timeval profile_time_end;
- long d;
-
- gettimeofday(&profile_time_end, NULL);
- d = time_sub(&profile_time_end, &profile_time_start);
-
- if (profile_tty)
- {
- if (fct_name[0])
- {
- if (strncmp(fct_name, f, sizeof(fct_name)))
- printf("\33[01;34m WARNING: %s ends before %s\33[0m\n",
- f, fct_name);
- }
- else
- printf("\33[01;34m WARNING: %s ends but we lost its start\33[0m\n",
- f);
-
- /* allow to detect missing PROFILE_END calls */
- fct_name[0] = '\0';
-
- if (rv != SCARD_S_SUCCESS)
- fprintf(stderr,
- "\33[01;31mRESULT %s \33[35m%ld \33[34m0x%08lX %s\33[0m\n",
- f, d, rv, pcsc_stringify_error(rv));
- else
- fprintf(stderr, "\33[01;31mRESULT %s \33[35m%ld\33[0m\n", f, d);
- }
- fprintf(profile_fd, "%s %ld\n", f, d);
- fflush(profile_fd);
-} /* profile_end */
-
-#else
-#define PROFILE_START
-#define PROFILE_END(rv)
-#endif
-
/**
* Represents an Application Context Channel.
* A channel belongs to an Application Context (\c _psContextMap).
@@ -390,8 +301,6 @@
int daemon_launched = FALSE;
int retries = 0;
- PROFILE_START
-
again:
/* Check if the server is running */
rv = SCardCheckDaemonAvailability();
@@ -478,8 +387,6 @@
}
end:
- PROFILE_END(rv)
-
return rv;
}
@@ -662,8 +569,6 @@
struct release_struct scReleaseStruct;
SCONTEXTMAP * currentContextMap;
- PROFILE_START
-
CHECK_SAME_PROCESS
/*
@@ -672,10 +577,7 @@
*/
currentContextMap = SCardGetContext(hContext);
if (NULL == currentContextMap)
- {
- PROFILE_END(SCARD_E_INVALID_HANDLE)
return SCARD_E_INVALID_HANDLE;
- }
(void)pthread_mutex_lock(currentContextMap->mMutex);
@@ -723,8 +625,6 @@
(void)SCardLockThread();
(void)SCardRemoveContext(hContext);
(void)SCardUnlockThread();
-
- PROFILE_END(rv)
return rv;
}
@@ -820,8 +720,6 @@
struct connect_struct scConnectStruct;
SCONTEXTMAP * currentContextMap;
- PROFILE_START
-
/*
* Check for NULL parameters
*/
@@ -904,8 +802,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -992,8 +888,6 @@
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
- PROFILE_START
-
if (pdwActiveProtocol == NULL)
return SCARD_E_INVALID_PARAMETER;
@@ -1064,8 +958,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -1108,8 +1000,6 @@
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
- PROFILE_START
-
CHECK_SAME_PROCESS
/*
@@ -1164,8 +1054,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -1213,8 +1101,6 @@
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
- PROFILE_START
-
CHECK_SAME_PROCESS
/*
@@ -1275,8 +1161,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv);
return rv;
}
@@ -1329,8 +1213,6 @@
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
- PROFILE_START
-
/*
* Zero out everything
*/
@@ -1394,8 +1276,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
- PROFILE_END(rv)
-
return rv;
}
@@ -1411,8 +1291,6 @@
struct cancel_transaction_struct scCancelStruct;
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
-
- PROFILE_START
CHECK_SAME_PROCESS
@@ -1462,8 +1340,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -1572,8 +1448,6 @@
LPBYTE bufAtr = NULL;
DWORD dummy;
- PROFILE_START
-
/* default output values */
if (pdwState)
*pdwState = 0;
@@ -1756,8 +1630,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -1868,8 +1740,6 @@
SCONTEXTMAP * currentContextMap;
int currentReaderCount = 0;
LONG rv = SCARD_S_SUCCESS;
-
- PROFILE_START
if ((rgReaderStates == NULL && cReaders > 0)
|| (cReaders > PCSCLITE_MAX_READERS_CONTEXTS))
@@ -2315,8 +2185,6 @@
(void)pthread_mutex_unlock(currentContextMap->mMutex);
- PROFILE_END(rv)
-
return rv;
}
@@ -2382,8 +2250,6 @@
SCONTEXTMAP * currentContextMap;
CHANNEL_MAP * pChannelMap;
- PROFILE_START
-
/* 0 bytes received by default */
if (NULL != lpBytesReturned)
*lpBytesReturned = 0;
@@ -2396,10 +2262,7 @@
rv = SCardGetContextAndChannelFromHandle(hCard, ¤tContextMap,
&pChannelMap);
if (rv == -1)
- {
- PROFILE_END(SCARD_E_INVALID_HANDLE)
return SCARD_E_INVALID_HANDLE;
- }
(void)pthread_mutex_lock(currentContextMap->mMutex);
@@ -2477,8 +2340,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -2593,8 +2454,6 @@
LONG ret;
unsigned char *buf = NULL;
- PROFILE_START
-
if (NULL == pcbAttrLen)
return SCARD_E_INVALID_PARAMETER;
@@ -2622,8 +2481,6 @@
ret = SCardGetSetAttrib(hCard, SCARD_GET_ATTRIB, dwAttrId, buf,
pcbAttrLen);
-
- PROFILE_END(ret)
return ret;
}
@@ -2668,15 +2525,11 @@
{
LONG ret;
- PROFILE_START
-
if (NULL == pbAttr || 0 == cbAttrLen)
return SCARD_E_INVALID_PARAMETER;
ret = SCardGetSetAttrib(hCard, SCARD_SET_ATTRIB, dwAttrId, (LPBYTE)pbAttr,
&cbAttrLen);
-
- PROFILE_END(ret)
return ret;
}
@@ -2840,8 +2693,6 @@
CHANNEL_MAP * pChannelMap;
struct transmit_struct scTransmitStruct;
- PROFILE_START
-
if (pbSendBuffer == NULL || pbRecvBuffer == NULL ||
pcbRecvLength == NULL || pioSendPci == NULL)
return SCARD_E_INVALID_PARAMETER;
@@ -2856,7 +2707,6 @@
if (rv == -1)
{
*pcbRecvLength = 0;
- PROFILE_END(SCARD_E_INVALID_HANDLE)
return SCARD_E_INVALID_HANDLE;
}
@@ -2962,8 +2812,6 @@
end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -3028,7 +2876,6 @@
char *buf = NULL;
(void)mszGroups;
- PROFILE_START
/*
* Check for NULL parameters
@@ -3043,10 +2890,7 @@
*/
currentContextMap = SCardGetContext(hContext);
if (NULL == currentContextMap)
- {
- PROFILE_END(SCARD_E_INVALID_HANDLE)
return SCARD_E_INVALID_HANDLE;
- }
(void)pthread_mutex_lock(currentContextMap->mMutex);
@@ -3126,8 +2970,6 @@
(void)pthread_mutex_unlock(currentContextMap->mMutex);
- PROFILE_END(rv)
-
return rv;
}
@@ -3149,8 +2991,6 @@
LONG rv = SCARD_S_SUCCESS;
SCONTEXTMAP * currentContextMap;
- PROFILE_START
-
CHECK_SAME_PROCESS
/*
@@ -3161,8 +3001,6 @@
return SCARD_E_INVALID_HANDLE;
free((void *)pvMem);
-
- PROFILE_END(rv)
return rv;
}
@@ -3224,8 +3062,6 @@
LONG rv = SCARD_S_SUCCESS;
SCONTEXTMAP * currentContextMap;
char *buf = NULL;
-
- PROFILE_START
/* Multi-string with two trailing \0 */
const char ReaderGroup[] = "SCard$DefaultReaders\0";
@@ -3283,8 +3119,6 @@
*pcchGroups = dwGroups;
(void)pthread_mutex_unlock(currentContextMap->mMutex);
-
- PROFILE_END(rv)
return rv;
}
@@ -3325,8 +3159,6 @@
uint32_t dwClientID = 0;
struct cancel_struct scCancelStruct;
- PROFILE_START
-
/*
* Make sure this context has been opened
*/
@@ -3371,8 +3203,6 @@
ClientCloseSession(dwClientID);
error:
- PROFILE_END(rv)
-
return rv;
}
@@ -3404,8 +3234,6 @@
LONG rv;
SCONTEXTMAP * currentContextMap;
- PROFILE_START
-
rv = SCARD_S_SUCCESS;
/* Check if the _same_ server is running */
@@ -3417,8 +3245,6 @@
currentContextMap = SCardGetContext(hContext);
if (currentContextMap == NULL)
rv = SCARD_E_INVALID_HANDLE;
-
- PROFILE_END(rv)
return rv;
}
More information about the Pcsclite-cvs-commit
mailing list