diff options
author | Jeremy Allison <jra@samba.org> | 2006-05-12 23:10:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:16:59 -0500 |
commit | 2602e5fab165d426e3a87e0cdcf8f7c67596e501 (patch) | |
tree | c439136a6659e59f4b96688b48e802ac29915ccf /source3/smbd | |
parent | c8baac2fd6fc9c83d44b93ff03d543353de9593c (diff) | |
download | samba-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')
-rw-r--r-- | source3/smbd/notify.c | 14 | ||||
-rw-r--r-- | source3/smbd/notify_hash.c | 20 | ||||
-rw-r--r-- | source3/smbd/service.c | 3 |
3 files changed, 33 insertions, 4 deletions
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index b2d0fc3326..829ca3a736 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -135,7 +135,19 @@ void remove_pending_change_notify_requests_by_filename(files_struct *fsp, NTSTAT } /**************************************************************************** - Return true if there are pending change notifies. + Set the current change notify timeout to the lowest value across all service + values. +****************************************************************************/ + +void set_change_notify_timeout(int val) +{ + if (val > 0) { + cnotify->select_time = MIN(cnotify->select_time, val); + } +} + +/**************************************************************************** + Longest time to sleep for before doing a change notify scan. ****************************************************************************/ int change_notify_timeout(void) 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; diff --git a/source3/smbd/service.c b/source3/smbd/service.c index ba87d0743d..7ca2380e0d 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -930,6 +930,9 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, dbgtext( "(pid %d)\n", (int)sys_getpid() ); } + /* Setup the minimum value for a change notify wait time (seconds). */ + set_change_notify_timeout(lp_change_notify_timeout(snum)); + /* we've finished with the user stuff - go back to root */ change_to_root_user(); return(conn); |