From 0e3bfa033ed230fcb46ad8e3c26c8b7aae6e00af Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Thu, 27 Oct 2011 17:53:47 -0400 Subject: [PATCH] auth: avoid excessive stat of cellservdb 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 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/auth/cellconfig.c | 7 +++++++ src/auth/cellconfig.p.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index b01ac456da..a230cbb44f 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -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) diff --git a/src/auth/cellconfig.p.h b/src/auth/cellconfig.p.h index a32742a892..94b72b942b 100644 --- a/src/auth/cellconfig.p.h +++ b/src/auth/cellconfig.p.h @@ -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; };