Use timers to determine whether or not to do the smart card present checks

or not.

bob
This commit is contained in:
relyea%netscape.com 2002-02-16 00:29:37 +00:00
Родитель 8c731969c2
Коммит 8f3c87eaa3
2 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -35,7 +35,7 @@
#define DEVT_H
#ifdef DEBUG
static const char DEVT_CVS_ID[] = "@(#) $RCSfile: devt.h,v $ $Revision: 1.9 $ $Date: 2002/02/01 17:25:11 $ $Name: $";
static const char DEVT_CVS_ID[] = "@(#) $RCSfile: devt.h,v $ $Revision: 1.10 $ $Date: 2002/02/16 00:29:37 $ $Name: $";
#endif /* DEBUG */
/*
@ -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 */

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.6 $ $Date: 2002/02/04 21:57:03 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.7 $ $Date: 2002/02/16 00:29:37 $ $Name: $";
#endif /* DEBUG */
#ifndef DEV_H
@ -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);