Windows: do not call time() in a loop
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 2 Apr 2012 11:10:17 +0000 (07:10 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 6 Apr 2012 15:03:22 +0000 (08:03 -0700)
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 <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_aclent.c

index 3c01da5..7e870bf 100644 (file)
@@ -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);