summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-10-19 08:36:17 +0000
committerJeremy Allison <jra@samba.org>2001-10-19 08:36:17 +0000
commite7f1c73b29c0af841288ec5e6c3d7b6d73525799 (patch)
treefb8525993649375a9a9f6f2d3f6c0bfdfac27e5b
parent27d8b68adbf132e375ede61ddaa51fe7d302640c (diff)
downloadsamba-e7f1c73b29c0af841288ec5e6c3d7b6d73525799.tar.gz
samba-e7f1c73b29c0af841288ec5e6c3d7b6d73525799.tar.xz
samba-e7f1c73b29c0af841288ec5e6c3d7b6d73525799.zip
Tidy up notify code, fix debug.
Jeremy.
-rw-r--r--source/smbd/notify.c32
-rw-r--r--source/smbd/notify_hash.c33
2 files changed, 37 insertions, 28 deletions
diff --git a/source/smbd/notify.c b/source/smbd/notify.c
index d0966289fe7..12e107bb3b9 100644
--- a/source/smbd/notify.c
+++ b/source/smbd/notify.c
@@ -22,7 +22,6 @@
#include "includes.h"
-extern int DEBUGLEVEL;
extern uint32 global_client_caps;
static struct cnotify_fns *cnotify;
@@ -31,7 +30,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 {
@@ -48,6 +47,7 @@ static struct change_notify *change_notify_list;
/****************************************************************************
Setup the common parts of the return packet and send it.
*****************************************************************************/
+
static void change_notify_reply_packet(char *inbuf, uint32 error_code)
{
char outbuf[smb_size+38];
@@ -80,10 +80,10 @@ static void change_notify_reply_packet(char *inbuf, uint32 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);
@@ -92,10 +92,10 @@ static void change_notify_remove(struct change_notify *cnbp)
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;
@@ -111,6 +111,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;
@@ -128,6 +129,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;
@@ -148,6 +150,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;
@@ -158,6 +161,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;
@@ -167,8 +171,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);
}
@@ -178,11 +183,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;
@@ -210,10 +216,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/source/smbd/notify_hash.c b/source/smbd/notify_hash.c
index 4eb7eb11eae..297fcfc17ce 100644
--- a/source/smbd/notify_hash.c
+++ b/source/smbd/notify_hash.c
@@ -22,9 +22,6 @@
#include "includes.h"
-extern int DEBUGLEVEL;
-
-
struct change_data {
time_t last_check_time; /* time we last checked this entry */
time_t modify_time; /* Info from the directory we're monitoring. */
@@ -33,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)
{
@@ -50,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;
@@ -76,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;
@@ -91,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);
@@ -110,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);
@@ -129,6 +131,7 @@ static void *hash_register_notify(connection_struct *conn, char *path, uint32 fl
Check if a change notify should be issued.
A time of zero means instantaneous check - don't modify the last check time.
*****************************************************************************/
+
static BOOL hash_check_notify(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *datap, time_t t)
{
struct change_data *data = (struct change_data *)datap;
@@ -162,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)
{
free(datap);
}
-
/****************************************************************************
-setup hash based change notify
+ Setup hash based change notify.
****************************************************************************/
+
struct cnotify_fns *hash_notify_init(void)
{
static struct cnotify_fns cnotify;
@@ -185,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);