auth: avoid excessive stat of cellservdb
authorMichael Meffie <mmeffie@sinenomine.net>
Thu, 27 Oct 2011 21:53:47 +0000 (17:53 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 18 Nov 2011 16:35:14 +0000 (08:35 -0800)
The modified time resolution is one second, so only
stat the cellservdb file at most only once per second.

Change-Id: I7d9a58f9af72b8c36b50374e49c07b4db85285e0
Reviewed-on: http://gerrit.openafs.org/5743
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/auth/cellconfig.c
src/auth/cellconfig.p.h

index b01ac45..a230cbb 100644 (file)
@@ -351,6 +351,12 @@ _afsconf_UpToDate(struct afsconf_dir *adir)
     char *cellservDB;
     struct stat tstat;
     int code;
+    time_t now = time(0);
+
+    if (adir->timeCheck == now) {
+       return 1; /* stat no more than once a second */
+    }
+    adir->timeCheck = now;
 
     _afsconf_CellServDBPath(adir, &cellservDB);
     if (cellservDB == NULL)
@@ -403,6 +409,7 @@ _afsconf_Touch(struct afsconf_dir *adir)
 #endif
 
     adir->timeRead = 0;                /* just in case */
+    adir->timeCheck = 0;
 
     _afsconf_CellServDBPath(adir, &cellservDB);
     if (cellservDB == NULL)
index a32742a..94b72b9 100644 (file)
@@ -94,6 +94,7 @@ struct afsconf_dir {
     struct afsconf_entry *entries;     /* list of cell entries */
     struct opr_queue keyList;          /* list of keys */
     afs_int32 timeRead;                /* time stamp of file last read */
+    afs_int32 timeCheck;       /* time of last check for update */
     struct afsconf_aliasentry *alias_entries;  /* cell aliases */
     afsconf_secflags securityFlags;
 };