From 5cdc211b8bf1b3f5419ebe52ecc9d3772ffdf9a6 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. Reviewed-on: http://gerrit.openafs.org/5743 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman (cherry picked from commit 0e3bfa033ed230fcb46ad8e3c26c8b7aae6e00af) Change-Id: Ia533d037cc772c085cfaad47035e2a29df64952e Reviewed-on: http://gerrit.openafs.org/9435 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- 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 7b21740c7..50de1084a 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -347,6 +347,12 @@ afsconf_Check(struct afsconf_dir *adir) #endif struct stat tstat; afs_int32 code; + time_t now = time(0); + + if (adir->timeCheck == now) { + return 0; /* stat no more than once a second */ + } + adir->timeCheck = now; #ifdef AFS_NT40_ENV /* NT client CellServDB has different file name than NT server or Unix */ @@ -398,6 +404,7 @@ afsconf_Touch(struct afsconf_dir *adir) #endif adir->timeRead = 0; /* just in case */ + adir->timeCheck = 0; #ifdef AFS_NT40_ENV /* NT client CellServDB has different file name than NT server or Unix */ diff --git a/src/auth/cellconfig.p.h b/src/auth/cellconfig.p.h index 67750ee2f..7b488b836 100644 --- a/src/auth/cellconfig.p.h +++ b/src/auth/cellconfig.p.h @@ -83,6 +83,7 @@ struct afsconf_dir { struct afsconf_entry *entries; /* list of cell entries */ struct afsconf_keys *keystr; /* structure containing 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 */ }; -- 2.39.5