summaryrefslogtreecommitdiff
path: root/source3/smbd/notify_hash.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-05-12 23:10:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:59 -0500
commit2602e5fab165d426e3a87e0cdcf8f7c67596e501 (patch)
treec439136a6659e59f4b96688b48e802ac29915ccf /source3/smbd/notify_hash.c
parentc8baac2fd6fc9c83d44b93ff03d543353de9593c (diff)
downloadsamba-2602e5fab165d426e3a87e0cdcf8f7c67596e501.tar.gz
samba-2602e5fab165d426e3a87e0cdcf8f7c67596e501.tar.bz2
samba-2602e5fab165d426e3a87e0cdcf8f7c67596e501.zip
r15555: Make "change notify timeout" a per-share parameter - used
when there's no kernel or FAM change notify. If set to zero this will turn off change notify for the share except when we ourselves change something (renames / deletes etc. ). Designed to help on large directory shares where a new changenotify is issued between each delete. This will be fixed correctly when we move to internal change notify (eg. back-port Samba4 changenotify). Jeremy. (This used to be commit 5a17bffbcd5082fde79c241468a0ff2b5903d540)
Diffstat (limited to 'source3/smbd/notify_hash.c')
-rw-r--r--source3/smbd/notify_hash.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/source3/smbd/notify_hash.c b/source3/smbd/notify_hash.c
index a98a028fae..0787a3eec5 100644
--- a/source3/smbd/notify_hash.c
+++ b/source3/smbd/notify_hash.c
@@ -81,6 +81,11 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags,
return True;
}
+ if (lp_change_notify_timeout(SNUM(conn)) <= 0) {
+ /* It change notify timeout has been disabled, never scan the directory. */
+ return True;
+ }
+
/*
* If we are to watch for changes that are only stored
* in inodes of files, not in the directory inode, we must
@@ -179,9 +184,17 @@ static BOOL hash_check_notify(connection_struct *conn, uint16 vuid, char *path,
{
struct change_data *data = (struct change_data *)datap;
struct change_data data2;
+ int cnto = lp_change_notify_timeout(SNUM(conn));
+
+ if (t && cnto <= 0) {
+ /* Change notify turned off on this share.
+ * Only scan when (t==0) - we think something changed. */
+ return False;
+ }
- if (t && t < data->last_check_time + lp_change_notify_timeout())
+ if (t && t < data->last_check_time + cnto) {
return False;
+ }
if (!change_to_user(conn,vuid))
return True;
@@ -201,8 +214,9 @@ static BOOL hash_check_notify(connection_struct *conn, uint16 vuid, char *path,
return True;
}
- if (t)
+ if (t) {
data->last_check_time = t;
+ }
change_to_root_user();
@@ -229,7 +243,7 @@ struct cnotify_fns *hash_notify_init(void)
cnotify.register_notify = hash_register_notify;
cnotify.check_notify = hash_check_notify;
cnotify.remove_notify = hash_remove_notify;
- cnotify.select_time = lp_change_notify_timeout();
+ cnotify.select_time = 60; /* Start with 1 minute default. */
cnotify.notification_fd = -1;
return &cnotify;