summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/notify.c14
-rw-r--r--source3/smbd/notify_hash.c20
-rw-r--r--source3/smbd/service.c3
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);