s3: Move the notify_ctx to the smbd_server_connection
authorVolker Lendecke <vl@samba.org>
Wed, 21 Mar 2012 11:18:09 +0000 (12:18 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 21 Mar 2012 13:26:06 +0000 (14:26 +0100)
We only need one notify_ctx per smbd. The notify_array can become quite large.
It's based on absolute paths, so there's no point in having a copy of the
complete array in memory multiple times.

Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Wed Mar 21 14:26:07 CET 2012 on sn-devel-104

source3/include/smb.h
source3/smbd/files.c
source3/smbd/globals.h
source3/smbd/notify.c
source3/smbd/service.c

index 86f69b4a066aabc5b60774c966640dd3097259fe..a12ca54d202b3cc6e8bc549c870473f11b57f610 100644 (file)
@@ -427,7 +427,6 @@ typedef struct connection_struct {
        name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */       
        struct dfree_cached_info *dfree_info;
        struct trans_state *pending_trans;
-       struct notify_context *notify_ctx;
 
        struct rpc_pipe_client *spoolss_pipe;
 
index 10a0b8169d09eb0cb1b45d30e69ddec70cf10f1d..6499a810ffc7300b9e75d90d269f5f53eafb4cba 100644 (file)
@@ -447,11 +447,13 @@ void file_free(struct smb_request *req, files_struct *fsp)
        }
 
        if (fsp->notify) {
+               struct notify_context *notify_ctx =
+                       fsp->conn->sconn->notify_ctx;
                if (fsp->is_directory) {
-                       notify_remove_onelevel(fsp->conn->notify_ctx,
+                       notify_remove_onelevel(notify_ctx,
                                               &fsp->file_id, fsp);
                }
-               notify_remove(fsp->conn->notify_ctx, fsp);
+               notify_remove(notify_ctx, fsp);
                TALLOC_FREE(fsp->notify);
        }
 
index caf7357df435cc760ddee779ce708edb9d28bbcd..3973855b7e2ac8a6ddd467ffff0fe520c591d6ce 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 notify_context *notify_ctx;
        struct {
                bool got_session;
        } nbt;
index 88e838ee178d6416d8ddd76d069fc102380b4893..8228c7597ef83b51572cedb44656d0b6c5669e9b 100644 (file)
@@ -221,7 +221,7 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
                e.subdir_filter = filter;
        }
 
-       status = notify_add(fsp->conn->notify_ctx, fsp->conn, &e,
+       status = notify_add(fsp->conn->sconn->notify_ctx, fsp->conn, &e,
                            notify_callback, fsp);
        TALLOC_FREE(fullpath);
 
@@ -364,6 +364,7 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
 void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
                  const char *path)
 {
+       struct notify_context *notify_ctx = conn->sconn->notify_ctx;
        char *fullpath;
        char *parent;
        const char *name;
@@ -378,7 +379,7 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
                smb_fname_parent.base_name = parent;
 
                if (SMB_VFS_STAT(conn, &smb_fname_parent) != -1) {
-                       notify_onelevel(conn->notify_ctx, action, filter,
+                       notify_onelevel(notify_ctx, action, filter,
                            SMB_VFS_FILE_ID_CREATE(conn, &smb_fname_parent.st),
                            name);
                }
@@ -390,7 +391,7 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
                DEBUG(0, ("asprintf failed\n"));
                return;
        }
-       notify_trigger(conn->notify_ctx, action, filter, fullpath);
+       notify_trigger(notify_ctx, action, filter, fullpath);
        TALLOC_FREE(fullpath);
 }
 
index 79e935d5d2db6e5761459d6921e8b63c96a083eb..d28a51a9a72fd661a0f33f7ab5ec6d8838ad25f7 100644 (file)
@@ -698,10 +698,11 @@ 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)) {
-               conn->notify_ctx = notify_init(conn,
-                                              sconn->msg_ctx,
-                                              sconn->ev_ctx);
+           lp_change_notify(conn->params) &&
+           sconn->notify_ctx == NULL) {
+               sconn->notify_ctx = notify_init(sconn,
+                                               sconn->msg_ctx,
+                                               sconn->ev_ctx);
        }
 
        /*