From: Jeffrey Altman Date: Mon, 2 Apr 2012 11:10:17 +0000 (-0400) Subject: Windows: do not call time() in a loop X-Git-Tag: upstream/1.8.0_pre1^2~2634 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=048b24ae2b8accb33bc92ab9fdc4cdda14bc425b;p=packages%2Fo%2Fopenafs.git Windows: do not call time() in a loop When checking for ACL Entry expiration, obtain the current time once per call to cm_FindACLCache() instead of once per ACL entry. Change-Id: I4da9e290a43315bd226f6c1b5dc12abe45ed19f5 Reviewed-on: http://gerrit.openafs.org/7016 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_aclent.c b/src/WINNT/afsd/cm_aclent.c index 3c01da5cd..7e870bf6c 100644 --- a/src/WINNT/afsd/cm_aclent.c +++ b/src/WINNT/afsd/cm_aclent.c @@ -72,6 +72,7 @@ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 *rightsp) { cm_aclent_t *aclp; long retval = -1; + time_t now = time(NULL); lock_ObtainWrite(&cm_aclLock); *rightsp = 0; /* get a new acl from server if we don't find a @@ -80,7 +81,7 @@ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 *rightsp) for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) { if (aclp->userp == userp) { - if (aclp->tgtLifetime && aclp->tgtLifetime <= time(NULL)) { + if (aclp->tgtLifetime && aclp->tgtLifetime <= now) { /* ticket expired */ osi_QRemoveHT((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); CleanupACLEnt(aclp);