From 6417a0e437342ec940125f5ed258db37d2f5dd50 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 17 Nov 2004 23:20:53 +0000 Subject: [PATCH] pullup from trunk ticket: 2756 version_fixed: 1.4 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-4@16885 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 10 ++++++++++ src/util/profile/prof_file.c | 22 ++++++++++++++++++++++ src/util/profile/prof_int.h | 5 +++++ 3 files changed, 37 insertions(+) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index b736e5d08..1499d25a0 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -11,6 +11,16 @@ file with profile_flush_to_file() or buffer with profile_flush_to_buffer(). +2004-10-30 Ken Raeburn + + * prof_int.h (STAT_ONCE_PER_SECOND): Define. + (struct _prf_data_t) [STAT_ONCE_PER_SECOND]: New field LAST_STAT. + * prof_file.c (scan_shared_trees_locked, + scan_shared_trees_unlocked): Redefine to do nothing for now. + (profile_update_file_data) [STAT_ONCE_PER_SECOND]: If the current + time is the same time as the last stat of the file, just return; + otherwise, save away the current time. + 2004-10-26 Ken Raeburn Permit exporting profile file data into a buffer. diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index f47e5404b..028253720 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -66,6 +66,8 @@ void profile_library_finalizer(void) static void profile_free_file_data(prf_data_t); +#if 0 + #define scan_shared_trees_locked() \ { \ prf_data_t d; \ @@ -89,6 +91,13 @@ static void profile_free_file_data(prf_data_t); k5_mutex_unlock(&g_shared_trees_mutex); \ } +#else + +#define scan_shared_trees_locked() { ; } +#define scan_shared_trees_unlocked() { ; } + +#endif + static int rw_access(const_profile_filespec_t filespec) { #ifdef HAVE_ACCESS @@ -295,6 +304,9 @@ errcode_t profile_update_file_data(prf_data_t data) errcode_t retval; #ifdef HAVE_STAT struct stat st; +#ifdef STAT_ONCE_PER_SECOND + time_t now; +#endif #endif FILE *f; @@ -303,11 +315,21 @@ errcode_t profile_update_file_data(prf_data_t data) return retval; #ifdef HAVE_STAT +#ifdef STAT_ONCE_PER_SECOND + now = time(0); + if (now == data->last_stat) { + k5_mutex_unlock(&data->lock); + return 0; + } +#endif if (stat(data->filespec, &st)) { retval = errno; k5_mutex_unlock(&data->lock); return retval; } +#ifdef STAT_ONCE_PER_SECOND + data->last_stat = now; +#endif if (st.st_mtime == data->timestamp) { k5_mutex_unlock(&data->lock); return 0; diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index d2761228c..b7c90961e 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -14,6 +14,8 @@ #include "com_err.h" #include "profile.h" +#define STAT_ONCE_PER_SECOND + #if defined(_WIN32) #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 @@ -36,6 +38,9 @@ struct _prf_data_t { k5_mutex_t lock; char *comment; struct profile_node *root; +#ifdef STAT_ONCE_PER_SECOND + time_t last_stat; +#endif time_t timestamp; /* time tree was last updated from file */ int flags; /* r/w, dirty */ int upd_serial; /* incremented when data changes */ -- 2.26.2