pullup from trunk
authorTom Yu <tlyu@mit.edu>
Wed, 17 Nov 2004 23:20:53 +0000 (23:20 +0000)
committerTom Yu <tlyu@mit.edu>
Wed, 17 Nov 2004 23:20:53 +0000 (23:20 +0000)
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
src/util/profile/prof_file.c
src/util/profile/prof_int.h

index b736e5d0817842b15924d6074ad2823bbca90b5f..1499d25a0214260d1ece683a8840b8d8c5f54d92 100644 (file)
         file with profile_flush_to_file() or buffer with 
         profile_flush_to_buffer().
 
+2004-10-30  Ken Raeburn  <raeburn@mit.edu>
+
+       * 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  <raeburn@mit.edu>
 
        Permit exporting profile file data into a buffer.
index f47e5404be92b050ab9a796d697e4f5d65dd7cd1..028253720690e2007221ccffd4d8628a047a1b40 100644 (file)
@@ -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;
index d2761228cb5205a0df7b597a46aeba8ee1fdb9ee..b7c90961e9f4997110da3094f6c40bbdd9c2d9bb 100644 (file)
@@ -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 */