From 4bb9cebf84e1addc135c18b1227e7c00e7c03163 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Oct 2001 08:37:32 +0000 Subject: Tidy up debug in notify code. Jeremy. (This used to be commit 7707c5e07385ce5ac3732715d586ad6c6b41de65) --- source3/smbd/notify.c | 30 ++++++++++++++++++------------ source3/smbd/notify_hash.c | 29 +++++++++++++++++------------ 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index 999821354e..d333e0f75a 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -28,7 +28,7 @@ static struct cnotify_fns *cnotify; This is the structure to queue to implement NT change notify. It consists of smb_size bytes stored from the transact command (to keep the mid, tid etc around). - Plus the fid to examine and notify private data + Plus the fid to examine and notify private data. *****************************************************************************/ struct change_notify { @@ -65,10 +65,10 @@ static void change_notify_reply_packet(char *inbuf, NTSTATUS error_code) } /**************************************************************************** -remove an entry from the list and free it, also closing any -directory handle if necessary -Notice the horrible stuff we have to do because this is a singly linked list. + Remove an entry from the list and free it, also closing any + directory handle if necessary. *****************************************************************************/ + static void change_notify_remove(struct change_notify *cnbp) { cnotify->remove_notify(cnbp->change_data); @@ -77,10 +77,10 @@ static void change_notify_remove(struct change_notify *cnbp) SAFE_FREE(cnbp); } - /**************************************************************************** Delete entries by fnum from the change notify pending queue. *****************************************************************************/ + void remove_pending_change_notify_requests_by_fid(files_struct *fsp) { struct change_notify *cnbp, *next; @@ -96,6 +96,7 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp) /**************************************************************************** Delete entries by mid from the change notify pending queue. Always send reply. *****************************************************************************/ + void remove_pending_change_notify_requests_by_mid(int mid) { struct change_notify *cnbp, *next; @@ -113,6 +114,7 @@ void remove_pending_change_notify_requests_by_mid(int mid) Delete entries by filename and cnum from the change notify pending queue. Always send reply. *****************************************************************************/ + void remove_pending_change_notify_requests_by_filename(files_struct *fsp) { struct change_notify *cnbp, *next; @@ -133,6 +135,7 @@ void remove_pending_change_notify_requests_by_filename(files_struct *fsp) /**************************************************************************** Return true if there are pending change notifies. ****************************************************************************/ + int change_notify_timeout(void) { return cnotify->select_time; @@ -143,6 +146,7 @@ int change_notify_timeout(void) Returns True if there are still outstanding change notify requests on the queue. *****************************************************************************/ + BOOL process_pending_change_notify_queue(time_t t) { struct change_notify *cnbp, *next; @@ -152,8 +156,9 @@ BOOL process_pending_change_notify_queue(time_t t) next=cnbp->next; vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID : SVAL(cnbp->request_buf,smb_uid); - + if (cnotify->check_notify(cnbp->conn, vuid, cnbp->fsp->fsp_name, cnbp->flags, cnbp->change_data, t)) { + DEBUG(10,("process_pending_change_notify_queue: dir %s changed !\n", cnbp->fsp->fsp_name )); change_notify_reply_packet(cnbp->request_buf,STATUS_NOTIFY_ENUM_DIR); change_notify_remove(cnbp); } @@ -163,11 +168,12 @@ BOOL process_pending_change_notify_queue(time_t t) } /**************************************************************************** - * Now queue an entry on the notify change list. - * We only need to save smb_size bytes from this incoming packet - * as we will always by returning a 'read the directory yourself' - * error. + Now queue an entry on the notify change list. + We only need to save smb_size bytes from this incoming packet + as we will always by returning a 'read the directory yourself' + error. ****************************************************************************/ + BOOL change_notify_set(char *inbuf, files_struct *fsp, connection_struct *conn, uint32 flags) { struct change_notify *cnbp; @@ -195,10 +201,10 @@ BOOL change_notify_set(char *inbuf, files_struct *fsp, connection_struct *conn, return True; } - /**************************************************************************** -initialise the change notify subsystem + Initialise the change notify subsystem. ****************************************************************************/ + BOOL init_change_notify(void) { #if HAVE_KERNEL_CHANGE_NOTIFY diff --git a/source3/smbd/notify_hash.c b/source3/smbd/notify_hash.c index d398fac214..415e4bcbda 100644 --- a/source3/smbd/notify_hash.c +++ b/source3/smbd/notify_hash.c @@ -30,10 +30,10 @@ struct change_data { unsigned int num_entries; /* Zero or the number of files in the directory. */ }; - /**************************************************************************** Create the hash we will use to determine if the contents changed. *****************************************************************************/ + static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags, struct change_data *data, struct change_data *old_data) { @@ -47,7 +47,8 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags, ZERO_STRUCTP(data); - if(vfs_stat(conn,path, &st) == -1) return False; + if(vfs_stat(conn,path, &st) == -1) + return False; data->modify_time = st.st_mtime; data->status_time = st.st_ctime; @@ -73,10 +74,12 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags, * larger than the max time_t value). */ - if (!(flags & (FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE))) return True; + if (!(flags & (FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE))) + return True; dp = OpenDir(conn, path, True); - if (dp == NULL) return False; + if (dp == NULL) + return False; data->num_entries = 0; @@ -88,7 +91,8 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags, p = &full_name[fullname_len]; while ((fname = ReadDirName(dp))) { - if(strequal(fname, ".") || strequal(fname, "..")) continue; + if(strequal(fname, ".") || strequal(fname, "..")) + continue; data->num_entries++; safe_strcpy(p, fname, remaining_len); @@ -107,15 +111,16 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags, return True; } - /**************************************************************************** -register a change notify request + Register a change notify request. *****************************************************************************/ + static void *hash_register_notify(connection_struct *conn, char *path, uint32 flags) { struct change_data data; - if (!notify_hash(conn, path, flags, &data, NULL)) return NULL; + if (!notify_hash(conn, path, flags, &data, NULL)) + return NULL; data.last_check_time = time(NULL); @@ -160,17 +165,18 @@ static BOOL hash_check_notify(connection_struct *conn, uint16 vuid, char *path, } /**************************************************************************** -remove a change notify data structure + Remove a change notify data structure. *****************************************************************************/ + static void hash_remove_notify(void *datap) { SAFE_FREE(datap); } - /**************************************************************************** -setup hash based change notify + Setup hash based change notify. ****************************************************************************/ + struct cnotify_fns *hash_notify_init(void) { static struct cnotify_fns cnotify; @@ -183,7 +189,6 @@ struct cnotify_fns *hash_notify_init(void) return &cnotify; } - /* change_notify_reply_packet(cnbp->request_buf,ERRSRV,ERRaccess); change_notify_reply_packet(cnbp->request_buf,0,NT_STATUS_NOTIFY_ENUM_DIR); -- cgit