s3: Remove the sys_notify dependency from notify_internal
authorVolker Lendecke <vl@samba.org>
Thu, 22 Mar 2012 13:58:24 +0000 (14:58 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 23 Mar 2012 11:12:51 +0000 (12:12 +0100)
Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Fri Mar 23 12:12:51 CET 2012 on sn-devel-104

source3/smbd/globals.h
source3/smbd/notify.c
source3/smbd/notify_internal.c
source3/smbd/proto.h
source3/smbd/service.c

index 3973855b7e2ac8a6ddd467ffff0fe520c591d6ce..56ee25148350a1d9c52ea3e0709ec2bee4cf7efe 100644 (file)
@@ -449,6 +449,7 @@ struct smbd_server_connection {
        const char *remote_hostname;
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
+       struct sys_notify_context *sys_notify_ctx;
        struct notify_context *notify_ctx;
        struct {
                bool got_session;
index 8228c7597ef83b51572cedb44656d0b6c5669e9b..53ae2d68e7911f05b140e03bb549f9f83c690c72 100644 (file)
@@ -174,13 +174,22 @@ static void notify_callback(void *private_data, const struct notify_event *e)
        notify_fsp(fsp, e->action, e->path);
 }
 
+static void sys_notify_callback(struct sys_notify_context *ctx,
+                               void *private_data,
+                               struct notify_event *e)
+{
+       files_struct *fsp = (files_struct *)private_data;
+       DEBUG(10, ("sys_notify_callback called for %s\n", fsp_str_dbg(fsp)));
+       notify_fsp(fsp, e->action, e->path);
+}
+
 NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
                              bool recursive)
 {
        char *fullpath;
        size_t len;
        struct notify_entry e;
-       NTSTATUS status;
+       NTSTATUS status = NT_STATUS_NOT_IMPLEMENTED;
 
        if (fsp->notify != NULL) {
                DEBUG(1, ("change_notify_create: fsp->notify != NULL, "
@@ -221,10 +230,24 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
                e.subdir_filter = filter;
        }
 
-       status = notify_add(fsp->conn->sconn->notify_ctx, fsp->conn, &e,
-                           notify_callback, fsp);
-       TALLOC_FREE(fullpath);
+       if (fsp->conn->sconn->sys_notify_ctx != NULL) {
+               void *sys_notify_handle = NULL;
+
+               status = SMB_VFS_NOTIFY_WATCH(
+                       fsp->conn, fsp->conn->sconn->sys_notify_ctx,
+                       &e, e.path, sys_notify_callback, fsp,
+                       &sys_notify_handle);
+
+               if (NT_STATUS_IS_OK(status)) {
+                       talloc_steal(fsp->notify, sys_notify_handle);
+               }
+       }
 
+       if ((e.filter != 0) || (e.subdir_filter != 0)) {
+               status = notify_add(fsp->conn->sconn->notify_ctx, fsp->conn,
+                                   &e, notify_callback, fsp);
+       }
+       TALLOC_FREE(fullpath);
        return status;
 }
 
@@ -545,17 +568,3 @@ struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
        ctx->private_data = NULL;
        return ctx;
 }
-
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
-                         connection_struct *conn,
-                         struct notify_entry *e,
-                         const char *path,
-                         void (*callback)(struct sys_notify_context *ctx, 
-                                          void *private_data,
-                                          struct notify_event *ev),
-                         void *private_data, void *handle)
-{
-       return SMB_VFS_NOTIFY_WATCH(conn, ctx, e, path, callback,
-                                   private_data, handle);
-}
-
index 63b7865b1315df50f8411c879b418a527be8ba93..c036e8a000684553ef4cf65c4d1385a0fb8cf0a2 100644 (file)
@@ -42,7 +42,6 @@ struct notify_context {
        struct notify_list *list;
        struct notify_array *array;
        int seqnum;
-       struct sys_notify_context *sys_notify_ctx;
        TDB_DATA key;
 };
 
@@ -51,7 +50,6 @@ struct notify_list {
        struct notify_list *next, *prev;
        void *private_data;
        void (*callback)(void *, const struct notify_event *);
-       void *sys_notify_handle;
        int depth;
 };
 
@@ -127,8 +125,6 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
        messaging_register(notify->messaging_ctx, notify,
                           MSG_PVFS_NOTIFY, notify_handler);
 
-       notify->sys_notify_ctx = sys_notify_context_create(notify, ev);
-
        return notify;
 }
 
@@ -340,19 +336,6 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
        talloc_free(tmp_ctx);
 }
 
-/*
-  callback from sys_notify telling us about changes from the OS
-*/
-static void sys_notify_callback(struct sys_notify_context *ctx,
-                               void *ptr, struct notify_event *ev)
-{
-       struct notify_list *listel = talloc_get_type(ptr, struct notify_list);
-       ev->private_data = listel;
-       DEBUG(10, ("sys_notify_callback called with action=%d, for %s\n",
-                  ev->action, ev->path));
-       listel->callback(listel->private_data, ev);
-}
-
 /*
   add an entry to the notify array
 */
@@ -528,21 +511,6 @@ NTSTATUS notify_add(struct notify_context *notify, connection_struct *conn,
        listel->depth = depth;
        DLIST_ADD(notify->list, listel);
 
-       /* ignore failures from sys_notify */
-       if (notify->sys_notify_ctx != NULL) {
-               /*
-                 this call will modify e.filter and e.subdir_filter
-                 to remove bits handled by the backend
-               */
-               status = sys_notify_watch(notify->sys_notify_ctx, conn,
-                                         &e, e.path,
-                                         sys_notify_callback, listel,
-                                         &listel->sys_notify_handle);
-               if (NT_STATUS_IS_OK(status)) {
-                       talloc_steal(listel, listel->sys_notify_handle);
-               }
-       }
-
        if (e.filter != 0) {
                notify_add_onelevel(notify, &e, private_data);
                status = NT_STATUS_OK;
index 07cfef5b5e080f9066c72b88dc16146f07a6ea46..70c34ce35a3863b0722779dfe76ba5f684880e81 100644 (file)
@@ -522,14 +522,6 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
 char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32 filter);
 struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
                                                     struct event_context *ev);
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
-                         connection_struct *conn,
-                         struct notify_entry *e,
-                         const char *path,
-                         void (*callback)(struct sys_notify_context *ctx,
-                                          void *private_data,
-                                          struct notify_event *ev),
-                         void *private_data, void *handle);
 
 /* The following definitions come from smbd/notify_inotify.c  */
 
index d28a51a9a72fd661a0f33f7ab5ec6d8838ad25f7..867776571b263b67b6c5605c89eb6a14b9a636df 100644 (file)
@@ -698,11 +698,15 @@ static NTSTATUS make_connection_snum(struct smbd_server_connection *sconn,
        on_err_call_dis_hook = true;
 
        if ((!conn->printer) && (!conn->ipc) &&
-           lp_change_notify(conn->params) &&
-           sconn->notify_ctx == NULL) {
-               sconn->notify_ctx = notify_init(sconn,
-                                               sconn->msg_ctx,
-                                               sconn->ev_ctx);
+           lp_change_notify(conn->params)) {
+               if (sconn->notify_ctx == NULL) {
+                       sconn->notify_ctx = notify_init(
+                               sconn, sconn->msg_ctx, sconn->ev_ctx);
+               }
+               if (sconn->sys_notify_ctx == NULL) {
+                       sconn->sys_notify_ctx = sys_notify_context_create(
+                               sconn, sconn->ev_ctx);
+               }
        }
 
        /*