From 200bd10b32107b4ce8fc72cc2abbf5a247708ba6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 31 Dec 2006 17:52:24 +0000 Subject: r20442: Slight rewrite of the change notify infrastructure. This now survives the first of the raw-notify subtests, the one-level test_notify_dir without any flags around yet. The tricky part was getting the data structures right, I hope the next tests don't let that fall over. fsp->notify is now by default NULL, meaning that nobody has issued a changenotify call. This means nobody is interested in changes for this directory. If that has happened, notify_change_buf collects the changes if no current request is outstanding, and it collects the requests if no change has happened since the last request. Happy New Year, somewhere on this planet it's already 2007 :-) Volker P.S: Jeremy, there's a question for you in smbd/files.c line 367. (This used to be commit ce0ad24988075465addcac0b9afc872e909135af) --- source3/smbd/files.c | 57 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'source3/smbd/files.c') diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 8df7a29a65..982de4c55f 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -100,12 +100,6 @@ NTSTATUS file_new(connection_struct *conn, files_struct **result) ZERO_STRUCTP(fsp->fh); - if (!(fsp->notify = TALLOC_ZERO_P(NULL, struct notify_changes))) { - SAFE_FREE(fsp->fh); - SAFE_FREE(fsp); - return NT_STATUS_NO_MEMORY; - } - fsp->fh->ref_count = 1; fsp->fh->fd = -1; @@ -367,33 +361,48 @@ files_struct *file_find_di_next(files_struct *start_fsp) return NULL; } -/**************************************************************************** - Find the directory fsp given a device and inode with the lowest - file_id. First use is for notify actions. -****************************************************************************/ +/* + * Same as file_find_di_first/next, but also finds non-fd opens. + * + * Jeremy, do we really need the fsp->fh->fd != -1 ?? + */ -files_struct *file_find_dir_lowest_id(SMB_DEV_T dev, SMB_INO_T inode) +struct files_struct *fsp_find_di_first(SMB_DEV_T dev, SMB_INO_T inode) { files_struct *fsp; - files_struct *min_fsp = NULL; - for (fsp = Files; fsp; fsp = fsp->next) { - if (!fsp->is_directory - || fsp->dev != dev || fsp->inode != inode) { - continue; - } + if (fsp_fi_cache.dev == dev && fsp_fi_cache.inode == inode) { + /* Positive or negative cache hit. */ + return fsp_fi_cache.fsp; + } - if (min_fsp == NULL) { - min_fsp = fsp; - continue; - } + fsp_fi_cache.dev = dev; + fsp_fi_cache.inode = inode; - if (fsp->fh->file_id < min_fsp->fh->file_id) { - min_fsp = fsp; + for (fsp=Files;fsp;fsp=fsp->next) { + if ((fsp->dev == dev) && (fsp->inode == inode)) { + /* Setup positive cache. */ + fsp_fi_cache.fsp = fsp; + return fsp; } } - return min_fsp; + /* Setup negative cache. */ + fsp_fi_cache.fsp = NULL; + return NULL; +} + +struct files_struct *fsp_find_di_next(files_struct *start_fsp) +{ + files_struct *fsp; + + for (fsp = start_fsp->next;fsp;fsp=fsp->next) { + if ( (fsp->dev == start_fsp->dev) + && (fsp->inode == start_fsp->inode) ) + return fsp; + } + + return NULL; } /**************************************************************************** -- cgit