The Samba-Bugzilla – Attachment 1263 Details for
Bug 2285
shortcut common cases for FindFirstChangeNotification calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
shortcut notification hash generation
notify-shortcut.patch (text/plain), 4.64 KB, created by
James Peach
on 2005-06-07 00:38:12 UTC
(
hide
)
Description:
shortcut notification hash generation
Filename:
MIME Type:
Creator:
James Peach
Created:
2005-06-07 00:38:12 UTC
Size:
4.64 KB
patch
obsolete
>Index: source/smbd/notify_hash.c >=================================================================== >--- source/smbd/notify_hash.c (revision 7349) >+++ source/smbd/notify_hash.c (working copy) >@@ -23,14 +23,28 @@ > > struct change_data { > time_t last_check_time; /* time we last checked this entry */ >+#ifdef HAVE_STAT_HIRES_TIMESTAMPS >+ struct timespec modify_time; >+ struct timespec status_time; >+#else > time_t modify_time; /* Info from the directory we're monitoring. */ > time_t status_time; /* Info from the directory we're monitoring. */ >+#endif > time_t total_time; /* Total time of all directory entries - don't care if it wraps. */ > unsigned int num_entries; /* Zero or the number of files in the directory. */ > unsigned int mode_sum; > unsigned char name_hash[16]; > }; > >+ >+#ifdef HAVE_STAT_HIRES_TIMESTAMPS >+/* Compare struct timespec. */ >+#define TIMESTAMP_NEQ(x, y) (((x).tv_sec != (y).tv_sec) || ((x).tv_nsec != (y).tv_nsec)) >+#else >+/* Compare time_t . */ >+#define TIMESTAMP_NEQ(x, y) ((x) != (y)) >+#endif >+ > /**************************************************************************** > Create the hash we will use to determine if the contents changed. > *****************************************************************************/ >@@ -52,20 +66,36 @@ > if(SMB_VFS_STAT(conn,path, &st) == -1) > return False; > >+#ifdef HAVE_STAT_HIRES_TIMESTAMPS >+ data->modify_time = st.st_mtim; >+ data->status_time = st.st_ctim; >+#else > data->modify_time = st.st_mtime; > data->status_time = st.st_ctime; >+#endif > > if (old_data) { > /* > * Shortcut to avoid directory scan if the time > * has changed - we always must return true then. > */ >- if (old_data->modify_time != data->modify_time || >- old_data->status_time != data->status_time ) { >+ if (TIMESTAMP_NEQ(old_data->modify_time, data->modify_time) || >+ TIMESTAMP_NEQ(old_data->status_time, data->status_time) ) { > return True; > } > } > >+ if (S_ISDIR(st.st_mode) && >+ (flags & ~(FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME)) == 0) >+ { >+ /* This is the case of a client wanting to know only when >+ * the contents of a directory changes. Since any file >+ * creation, rename or deletion will update the directory >+ * timestamps, we don't need to create a hash. >+ */ >+ return True; >+ } >+ > /* > * If we are to watch for changes that are only stored > * in inodes of files, not in the directory inode, we must >@@ -176,8 +206,8 @@ > } > > if (!notify_hash(conn, path, flags, &data2, data) || >- data2.modify_time != data->modify_time || >- data2.status_time != data->status_time || >+ TIMESTAMP_NEQ(data2.modify_time, data->modify_time) || >+ TIMESTAMP_NEQ(data2.status_time, data->status_time) || > data2.total_time != data->total_time || > data2.num_entries != data->num_entries || > data2.mode_sum != data->mode_sum || >Index: source/configure.in >=================================================================== >--- source/configure.in (revision 7349) >+++ source/configure.in (working copy) >@@ -1142,6 +1142,57 @@ > fi > fi > >+################################################# >+# Check whether struct stat has timestamps with sub-second resolution. >+# At least IRIX and Solaris have these. >+# >+# We check that >+# all of st_mtim, st_atim and st_ctim exist >+# all of the members are in fact of type struct timespec >+# >+# There is some conflicting standards weirdness about whether we should use >+# "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we >+# prefer struct timespec. >+ >+AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires, >+ [ >+ AC_TRY_COMPILE( >+ [ >+#if TIME_WITH_SYS_TIME >+# include <sys/time.h> >+# include <time.h> >+#else >+# if HAVE_SYS_TIME_H >+# include <sys/time.h> >+# else >+# include <time.h> >+# endif >+#endif >+#ifdef HAVE_SYS_STAT_H >+#include <sys/stat.h> >+#endif >+ ], >+ [ >+ struct timespec t; >+ struct stat s = {0}; >+ t.tv_sec = s.st_mtim.tv_sec; >+ t.tv_nsec = s.st_mtim.tv_nsec; >+ t.tv_sec = s.st_ctim.tv_sec; >+ t.tv_nsec = s.st_ctim.tv_nsec; >+ t.tv_sec = s.st_atim.tv_sec; >+ t.tv_nsec = s.st_atim.tv_nsec; >+ ], >+ samba_stat_hires=yes, samba_stat_hires=no) >+ ]) >+ >+if test x"$samba_stat_hires" = x"yes" ; then >+ AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim]) >+ AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim]) >+ AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim]) >+ AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1, >+ [whether struct stat has sub-second timestamps]) >+fi >+ > ##################################### > # we might need the resolv library on some systems > AC_CHECK_LIB(resolv, dn_expand)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 2285
:
920
| 1263