summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2002-02-16 00:29:37 +0000
committerrelyea%netscape.com <devnull@localhost>2002-02-16 00:29:37 +0000
commite74e7318f015616ec02f15c9777db51e7a3b2f9c (patch)
tree513cbed56355380c020aafb22b164c03dd54aa5f
parentef73ed4f08240534fa86dfe289d030f9c7019f9d (diff)
downloadnss-hg-e74e7318f015616ec02f15c9777db51e7a3b2f9c.tar.gz
Use timers to determine whether or not to do the smart card present checks
or not. bob
-rw-r--r--security/nss/lib/dev/devt.h1
-rw-r--r--security/nss/lib/dev/devtoken.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/security/nss/lib/dev/devt.h b/security/nss/lib/dev/devt.h
index cc681f9c2..148ad7683 100644
--- a/security/nss/lib/dev/devt.h
+++ b/security/nss/lib/dev/devt.h
@@ -131,6 +131,7 @@ struct NSSTokenStr
void *epv;
nssSession *defaultSession;
NSSTrustDomain *trustDomain;
+ PRIntervalTime lastTime;
#ifdef NSS_3_4_CODE
PK11SlotInfo *pk11slot;
nssList *certList; /* local cache of certs for slow tokens */
diff --git a/security/nss/lib/dev/devtoken.c b/security/nss/lib/dev/devtoken.c
index caddae84c..cdd0fc9ac 100644
--- a/security/nss/lib/dev/devtoken.c
+++ b/security/nss/lib/dev/devtoken.c
@@ -207,11 +207,25 @@ nssToken_IsPresent
nssSession *session;
CK_SLOT_INFO slotInfo;
NSSSlot *slot = token->slot;
+ PRIntervalTime time,lastTime;
+ static PRIntervalTime delayTime = 0;
+
session = token->defaultSession;
/* permanent slots are always present */
if (nssSlot_IsPermanent(slot) && session != CK_INVALID_SESSION) {
return PR_TRUE;
}
+
+ if (delayTime == 0) {
+ delayTime = PR_SecondsToInterval(10);
+ }
+
+ time = PR_IntervalNow();
+ lastTime = token->lastTime;
+ if ((time > lastTime) && ((time - lastTime) < delayTime)) {
+ return (PRBool) ((slot->ckFlags & CKF_TOKEN_PRESENT) != 0);
+ }
+ token->lastTime = time;
nssSession_EnterMonitor(session);
/* First obtain the slot info */
ckrv = CKAPI(slot)->C_GetSlotInfo(slot->slotID, &slotInfo);