From 1cc7abf8aada94be6f35f1f81edd248801d8fe5a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 22 Mar 2012 14:58:24 +0100 Subject: s3: Remove the sys_notify dependency from notify_internal Autobuild-User: Volker Lendecke Autobuild-Date: Fri Mar 23 12:12:51 CET 2012 on sn-devel-104 --- source3/smbd/globals.h | 1 + source3/smbd/notify.c | 45 +++++++++++++++++++++++++----------------- source3/smbd/notify_internal.c | 32 ------------------------------ source3/smbd/proto.h | 8 -------- source3/smbd/service.c | 14 ++++++++----- 5 files changed, 37 insertions(+), 63 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 3973855b7e..56ee251483 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -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; diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index 8228c7597e..53ae2d68e7 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -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); -} - diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c index 63b7865b13..c036e8a000 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -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; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 07cfef5b5e..70c34ce35a 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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 */ diff --git a/source3/smbd/service.c b/source3/smbd/service.c index d28a51a9a7..867776571b 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -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); + } } /* -- cgit