From 3434cd778c975eb1bb29d257770bd6dbb2335ce9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Mar 2006 11:47:24 +0000 Subject: r14616: added notify change support to the posix backend It doesn't fully work yet, and doesn't yet have all the efficiency that is planned, but it doesn't break anything and I wanted to get the code in the tree to minimise the chance of collisions with the work metze is doing. (This used to be commit 1624ea88e6eef89caacc36e7513aa79df0d579b9) --- source4/ntvfs/common/notify.c | 402 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 402 insertions(+) create mode 100644 source4/ntvfs/common/notify.c (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c new file mode 100644 index 0000000000..48b3559b36 --- /dev/null +++ b/source4/ntvfs/common/notify.c @@ -0,0 +1,402 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + this is the change notify database. It implements mechanisms for + storing current change notify waiters in a tdb, and checking if a + given event matches any of the stored notify waiiters. +*/ + +#include "includes.h" +#include "system/filesys.h" +#include "lib/tdb/include/tdb.h" +#include "lib/tdb/include/tdbutil.h" +#include "messaging/messaging.h" +#include "db_wrap.h" +#include "smb_server/smb_server.h" +#include "lib/messaging/irpc.h" +#include "librpc/gen_ndr/ndr_notify.h" +#include "dlinklist.h" + +struct notify_context { + struct tdb_wrap *w; + uint32_t server; + struct messaging_context *messaging_ctx; + struct notify_list *list; + struct notify_array *array; +}; + + +struct notify_list { + struct notify_list *next, *prev; + void *private; + void (*callback)(void *, const struct notify_event *); +}; + +#define NOTIFY_KEY "notify array" + +static NTSTATUS notify_remove_all(struct notify_context *notify); +static void notify_handler(struct messaging_context *msg_ctx, void *private, + uint32_t msg_type, uint32_t server_id, DATA_BLOB *data); + +/* + destroy the notify context +*/ +static int notify_destructor(void *p) +{ + struct notify_context *notify = talloc_get_type(p, struct notify_context); + messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify); + notify_remove_all(notify); + return 0; +} + +/* + Open up the notify.tdb database. You should close it down using + talloc_free(). We need the messaging_ctx to allow for notifications + via internal messages +*/ +struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, + struct messaging_context *messaging_ctx) +{ + char *path; + struct notify_context *notify; + + notify = talloc(mem_ctx, struct notify_context); + if (notify == NULL) { + return NULL; + } + + path = smbd_tmp_path(notify, "notify.tdb"); + notify->w = tdb_wrap_open(notify, path, 0, + TDB_DEFAULT, + O_RDWR|O_CREAT, 0600); + talloc_free(path); + if (notify->w == NULL) { + talloc_free(notify); + return NULL; + } + + notify->server = server; + notify->messaging_ctx = messaging_ctx; + notify->list = NULL; + notify->array = NULL; + + talloc_set_destructor(notify, notify_destructor); + + /* register with the messaging subsystem for the notify + message type */ + messaging_register(notify->messaging_ctx, notify, + MSG_PVFS_NOTIFY, notify_handler); + + return notify; +} + +/* + load the notify array +*/ +static NTSTATUS notify_load(struct notify_context *notify) +{ + TDB_DATA dbuf; + DATA_BLOB blob; + NTSTATUS status; + + talloc_free(notify->array); + notify->array = talloc_zero(notify, struct notify_array); + NT_STATUS_HAVE_NO_MEMORY(notify->array); + + dbuf = tdb_fetch_bystring(notify->w->tdb, NOTIFY_KEY); + if (dbuf.dptr == NULL) { + return NT_STATUS_OK; + } + + blob.data = dbuf.dptr; + blob.length = dbuf.dsize; + + status = ndr_pull_struct_blob(&blob, notify->array, notify->array, + (ndr_pull_flags_fn_t)ndr_pull_notify_array); + free(dbuf.dptr); + + return status; +} + + +/* + save the notify array +*/ +static NTSTATUS notify_save(struct notify_context *notify) +{ + TDB_DATA dbuf; + DATA_BLOB blob; + NTSTATUS status; + int ret; + TALLOC_CTX *tmp_ctx; + + if (notify->array->num_entries == 0) { + ret = tdb_delete_bystring(notify->w->tdb, NOTIFY_KEY); + if (ret != 0) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + return NT_STATUS_OK; + } + + tmp_ctx = talloc_new(notify); + + status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, + (ndr_push_flags_fn_t)ndr_push_notify_array); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return status; + } + + dbuf.dptr = blob.data; + dbuf.dsize = blob.length; + + ret = tdb_store_bystring(notify->w->tdb, NOTIFY_KEY, dbuf, TDB_REPLACE); + talloc_free(tmp_ctx); + if (ret != 0) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + return NT_STATUS_OK; +} + + +/* + handle incoming notify messages +*/ +static void notify_handler(struct messaging_context *msg_ctx, void *private, + uint32_t msg_type, uint32_t server_id, DATA_BLOB *data) +{ + struct notify_context *notify = talloc_get_type(private, struct notify_context); + NTSTATUS status; + struct notify_event ev; + TALLOC_CTX *tmp_ctx = talloc_new(notify); + struct notify_list *listel; + + status = ndr_pull_struct_blob(data, tmp_ctx, &ev, + (ndr_pull_flags_fn_t)ndr_pull_notify_event); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return; + } + + for (listel=notify->list;listel;listel=listel->next) { + if (listel->private == ev.private) { + listel->callback(listel->private, &ev); + break; + } + } + + talloc_free(tmp_ctx); +} + +/* + add a notify watch. This is called when a notify is first setup on a open + directory handle. +*/ +NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, + void (*callback)(void *, const struct notify_event *), + void *private) +{ + NTSTATUS status; + struct notify_list *listel; + + status = notify_load(notify); + NT_STATUS_NOT_OK_RETURN(status); + + notify->array->entries = talloc_realloc(notify->array, notify->array->entries, + struct notify_entry, + notify->array->num_entries+1); + + if (notify->array->entries == NULL) { + return NT_STATUS_NO_MEMORY; + } + + notify->array->entries[notify->array->num_entries] = *e; + notify->array->entries[notify->array->num_entries].private = private; + notify->array->entries[notify->array->num_entries].server = notify->server; + notify->array->num_entries++; + + status = notify_save(notify); + NT_STATUS_NOT_OK_RETURN(status); + + listel = talloc(notify, struct notify_list); + NT_STATUS_HAVE_NO_MEMORY(listel); + + listel->private = private; + listel->callback = callback; + DLIST_ADD(notify->list, listel); + + return status; +} + +/* + remove a notify watch. Called when the directory handle is closed +*/ +NTSTATUS notify_remove(struct notify_context *notify, void *private) +{ + NTSTATUS status; + struct notify_list *listel; + int i; + + for (listel=notify->list;listel;listel=listel->next) { + if (listel->private == private) { + DLIST_REMOVE(notify->list, listel); + break; + } + } + if (listel == NULL) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + status = notify_load(notify); + NT_STATUS_NOT_OK_RETURN(status); + + for (i=0;iarray->num_entries;i++) { + if (notify->server == notify->array->entries[i].server && + private == notify->array->entries[i].private) { + break; + } + } + if (i == notify->array->num_entries) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (i < notify->array->num_entries-1) { + memmove(¬ify->array->entries[i], ¬ify->array->entries[i+1], + sizeof(notify->array->entries[i])*(notify->array->num_entries-(i+1))); + } + notify->array->num_entries--; + + return notify_save(notify); +} + +/* + remove all notify watches for this messaging server +*/ +static NTSTATUS notify_remove_all(struct notify_context *notify) +{ + NTSTATUS status; + int i; + + if (notify->list == NULL) { + return NT_STATUS_OK; + } + + status = notify_load(notify); + NT_STATUS_NOT_OK_RETURN(status); + + for (i=0;iarray->num_entries;i++) { + if (notify->server == notify->array->entries[i].server) { + if (i < notify->array->num_entries-1) { + memmove(¬ify->array->entries[i], ¬ify->array->entries[i+1], + sizeof(notify->array->entries[i])*(notify->array->num_entries-(i+1))); + } + i--; + notify->array->num_entries--; + } + } + + + return notify_save(notify); +} + + +/* + see if a notify event matches +*/ +static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, + const char *path, uint32_t action) +{ + size_t len = strlen(e->path); + + /* TODO: check action */ + + if (strncmp(path, e->path, len) != 0) { + return False; + } + + if (path[len] == 0) { + return True; + } + if (path[len] != '/') { + return False; + } + + if (!e->recursive) { + if (strchr(&path[len+1], '/') != NULL) { + return False; + } + } + + return True; +} + + +/* + send a notify message to another messaging server +*/ +static void notify_send(struct notify_context *notify, struct notify_entry *e, + const char *path, uint32_t action) +{ + struct notify_event ev; + DATA_BLOB data; + NTSTATUS status; + TALLOC_CTX *tmp_ctx; + + ev.action = action; + ev.path = path; + ev.private = e->private; + + tmp_ctx = talloc_new(notify); + + status = ndr_push_struct_blob(&data, tmp_ctx, &ev, + (ndr_push_flags_fn_t)ndr_push_notify_event); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return; + } + + status = messaging_send(notify->messaging_ctx, e->server, + MSG_PVFS_NOTIFY, &data); + talloc_free(tmp_ctx); +} + +/* + trigger a notify message for anyone waiting on a matching event +*/ +void notify_trigger(struct notify_context *notify, + uint32_t action, const char *path) +{ + NTSTATUS status; + int i; + + status = notify_load(notify); + if (!NT_STATUS_IS_OK(status)) { + return; + } + + /* this needs to be changed to a log(n) search */ + for (i=0;iarray->num_entries;i++) { + if (notify_match(notify, ¬ify->array->entries[i], path, action)) { + notify_send(notify, ¬ify->array->entries[i], path, action); + } + } +} -- cgit From ad06a8bd651e3a8b598c92a356ac1ce4117ae72e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 26 Mar 2006 01:23:40 +0000 Subject: r14736: - the ntvfs subsystem should not know about smb_server.h - the process module subsystem should not know about smb_server.h - the smb_server module should not know about process models metze (This used to be commit bac95bb8f4ad35a31ee666f5916ff9b2f292d964) --- source4/ntvfs/common/notify.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 48b3559b36..604b6a1a2d 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -30,7 +30,6 @@ #include "lib/tdb/include/tdbutil.h" #include "messaging/messaging.h" #include "db_wrap.h" -#include "smb_server/smb_server.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" #include "dlinklist.h" -- cgit From 57bde8631fc65f9b8e10eee7f948e5690412bead Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Mar 2006 13:31:30 +0000 Subject: r14755: the change notify code now passes most of the RAW-NOTIFY test. Still more work to do though (This used to be commit 4d234b37e528137b5c00f6bbb84c2d6939fea324) --- source4/ntvfs/common/notify.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 604b6a1a2d..bc04c830f1 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -332,9 +332,6 @@ static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, return False; } - if (path[len] == 0) { - return True; - } if (path[len] != '/') { return False; } @@ -395,7 +392,9 @@ void notify_trigger(struct notify_context *notify, /* this needs to be changed to a log(n) search */ for (i=0;iarray->num_entries;i++) { if (notify_match(notify, ¬ify->array->entries[i], path, action)) { - notify_send(notify, ¬ify->array->entries[i], path, action); + notify_send(notify, ¬ify->array->entries[i], + path + strlen(notify->array->entries[i].path) + 1, + action); } } } -- cgit From ed3fc628713e1f9552b523c9aec9bd8993e0b771 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Mar 2006 03:51:49 +0000 Subject: r14797: added checking of the filter in notify requests (This used to be commit 1db0a5a7f4c1ff915d91bc15d8e40cc90a78961d) --- source4/ntvfs/common/notify.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index bc04c830f1..c5acf9decb 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -322,11 +322,15 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) see if a notify event matches */ static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, - const char *path, uint32_t action) + const char *path, uint32_t filter) { - size_t len = strlen(e->path); + size_t len; - /* TODO: check action */ + if (!(filter & e->filter)) { + return False; + } + + len = strlen(e->path); if (strncmp(path, e->path, len) != 0) { return False; @@ -379,7 +383,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, trigger a notify message for anyone waiting on a matching event */ void notify_trigger(struct notify_context *notify, - uint32_t action, const char *path) + uint32_t action, uint32_t filter, const char *path) { NTSTATUS status; int i; @@ -391,7 +395,7 @@ void notify_trigger(struct notify_context *notify, /* this needs to be changed to a log(n) search */ for (i=0;iarray->num_entries;i++) { - if (notify_match(notify, ¬ify->array->entries[i], path, action)) { + if (notify_match(notify, ¬ify->array->entries[i], path, filter)) { notify_send(notify, ¬ify->array->entries[i], path + strlen(notify->array->entries[i].path) + 1, action); -- cgit From 24bacd111334b34d4c52135eea9b466e3a28a8f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Mar 2006 04:55:03 +0000 Subject: r14800: use tdb_get_seqnum() in the change notify code to avoid reloading the notify record if the tdb has not changed. This makes the notify_trigger() call much faster, which is important as it is called on just about every file operation (This used to be commit d09b8761bfda7dfbb4c7a5c4a4f4359ba01923a3) --- source4/ntvfs/common/notify.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index c5acf9decb..b71c2906ae 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -40,6 +40,7 @@ struct notify_context { struct messaging_context *messaging_ctx; struct notify_list *list; struct notify_array *array; + int seqnum; }; @@ -84,8 +85,8 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, path = smbd_tmp_path(notify, "notify.tdb"); notify->w = tdb_wrap_open(notify, path, 0, - TDB_DEFAULT, - O_RDWR|O_CREAT, 0600); + TDB_SEQNUM, + O_RDWR|O_CREAT, 0600); talloc_free(path); if (notify->w == NULL) { talloc_free(notify); @@ -96,6 +97,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, notify->messaging_ctx = messaging_ctx; notify->list = NULL; notify->array = NULL; + notify->seqnum = tdb_get_seqnum(notify->w->tdb); talloc_set_destructor(notify, notify_destructor); @@ -115,6 +117,15 @@ static NTSTATUS notify_load(struct notify_context *notify) TDB_DATA dbuf; DATA_BLOB blob; NTSTATUS status; + int seqnum; + + seqnum = tdb_get_seqnum(notify->w->tdb); + + if (seqnum == notify->seqnum && notify->array != NULL) { + return NT_STATUS_OK; + } + + notify->seqnum = seqnum; talloc_free(notify->array); notify->array = talloc_zero(notify, struct notify_array); -- cgit From aec7f3ae721bff48e63cc3abcee07b18fa13417a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Mar 2006 05:45:43 +0000 Subject: r14803: copy with the root directory, which has /. on the end of the path (This used to be commit 16742cd28621d205f21c855e5635be1dfc3f2b69) --- source4/ntvfs/common/notify.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index b71c2906ae..52abc08d74 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -227,6 +227,8 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, { NTSTATUS status; struct notify_list *listel; + char *path = NULL; + size_t len; status = notify_load(notify); NT_STATUS_NOT_OK_RETURN(status); @@ -239,14 +241,29 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, return NT_STATUS_NO_MEMORY; } + /* cope with /. on the end of the path */ + len = strlen(e->path); + if (len > 1 && e->path[len-1] == '.' && e->path[len-2] == '/') { + path = talloc_strndup(notify, e->path, len-2); + } + notify->array->entries[notify->array->num_entries] = *e; notify->array->entries[notify->array->num_entries].private = private; notify->array->entries[notify->array->num_entries].server = notify->server; + + if (path) { + notify->array->entries[notify->array->num_entries].path = path; + } + notify->array->num_entries++; status = notify_save(notify); NT_STATUS_NOT_OK_RETURN(status); + if (path) { + talloc_free(path); + } + listel = talloc(notify, struct notify_list); NT_STATUS_HAVE_NO_MEMORY(listel); -- cgit From 6942d1d62c23ea2e43469485c0e0503d3906760c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Mar 2006 06:07:38 +0000 Subject: r14805: use tdb_lock_bystring() to prevent race conditions in notify add/remove (This used to be commit a6be44f78ca2eaecbf0b6d8598addba5a11ae966) --- source4/ntvfs/common/notify.c | 61 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 52abc08d74..dd39aca095 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -109,6 +109,26 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, return notify; } + +/* + lock the notify db +*/ +static NTSTATUS notify_lock(struct notify_context *notify) +{ + if (tdb_lock_bystring(notify->w->tdb, NOTIFY_KEY) != 0) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + return NT_STATUS_OK; +} + +/* + unlock the notify db +*/ +static void notify_unlock(struct notify_context *notify) +{ + tdb_unlock_bystring(notify->w->tdb, NOTIFY_KEY); +} + /* load the notify array */ @@ -230,14 +250,21 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, char *path = NULL; size_t len; - status = notify_load(notify); + status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); + status = notify_load(notify); + if (!NT_STATUS_IS_OK(status)) { + notify_unlock(notify); + return status; + } + notify->array->entries = talloc_realloc(notify->array, notify->array->entries, struct notify_entry, notify->array->num_entries+1); if (notify->array->entries == NULL) { + notify_unlock(notify); return NT_STATUS_NO_MEMORY; } @@ -258,6 +285,9 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, notify->array->num_entries++; status = notify_save(notify); + + notify_unlock(notify); + NT_STATUS_NOT_OK_RETURN(status); if (path) { @@ -293,9 +323,15 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - status = notify_load(notify); + status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); + status = notify_load(notify); + if (!NT_STATUS_IS_OK(status)) { + notify_unlock(notify); + return status; + } + for (i=0;iarray->num_entries;i++) { if (notify->server == notify->array->entries[i].server && private == notify->array->entries[i].private) { @@ -303,6 +339,7 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) } } if (i == notify->array->num_entries) { + notify_unlock(notify); return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -312,7 +349,11 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) } notify->array->num_entries--; - return notify_save(notify); + status = notify_save(notify); + + notify_unlock(notify); + + return status; } /* @@ -327,9 +368,15 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) return NT_STATUS_OK; } - status = notify_load(notify); + status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); + status = notify_load(notify); + if (!NT_STATUS_IS_OK(status)) { + notify_unlock(notify); + return status; + } + for (i=0;iarray->num_entries;i++) { if (notify->server == notify->array->entries[i].server) { if (i < notify->array->num_entries-1) { @@ -342,7 +389,11 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) } - return notify_save(notify); + status = notify_save(notify); + + notify_unlock(notify); + + return status; } -- cgit From 6d98076c15e8726606da0a99714cd3382d82f9ac Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Apr 2006 06:46:55 +0000 Subject: r14877: added support for the kernel inotify mechanism. This passes basic tests, but still needs some more work to ensure we correctly cope with events that may generate both a system inotify event and a internal notify event. The system inotify events won't handle recursion, and don't understand things like streams. This also adds the ntvfs/sysdep/ directory, which is meant for system dependent code that is not tied to a particular ntvfs backend. The inotify code is a good example of that. (This used to be commit eadadbb44adb3c4081d6ff1d85a9b850a0227059) --- source4/ntvfs/common/notify.c | 137 +++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 48 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index dd39aca095..595a0f6566 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -33,6 +33,7 @@ #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" #include "dlinklist.h" +#include "ntvfs/sysdep/sys_notify.h" struct notify_context { struct tdb_wrap *w; @@ -41,6 +42,7 @@ struct notify_context { struct notify_list *list; struct notify_array *array; int seqnum; + struct sys_notify_context *sys_notify_ctx; }; @@ -48,6 +50,7 @@ struct notify_list { struct notify_list *next, *prev; void *private; void (*callback)(void *, const struct notify_event *); + void *sys_notify_handle; }; #define NOTIFY_KEY "notify array" @@ -73,7 +76,8 @@ static int notify_destructor(void *p) via internal messages */ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, - struct messaging_context *messaging_ctx) + struct messaging_context *messaging_ctx, + struct event_context *ev) { char *path; struct notify_context *notify; @@ -106,6 +110,8 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, messaging_register(notify->messaging_ctx, notify, MSG_PVFS_NOTIFY, notify_handler); + notify->sys_notify_ctx = sys_notify_init(-1, notify, ev); + return notify; } @@ -166,6 +172,14 @@ static NTSTATUS notify_load(struct notify_context *notify) return status; } +/* + compare notify entries for sorting +*/ +static int notify_compare(const void *p1, const void *p2) +{ + const struct notify_entry *e1 = p1, *e2 = p2; + return strcmp(e1->path, e2->path); +} /* save the notify array @@ -186,6 +200,11 @@ static NTSTATUS notify_save(struct notify_context *notify) return NT_STATUS_OK; } + if (notify->array->num_entries > 1) { + qsort(notify->array->entries, notify->array->num_entries, + sizeof(struct notify_entry), notify_compare); + } + tmp_ctx = talloc_new(notify); status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, @@ -237,6 +256,17 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private, 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 = listel; + listel->callback(listel->private, ev); +} + /* add a notify watch. This is called when a notify is first setup on a open directory handle. @@ -274,33 +304,42 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, path = talloc_strndup(notify, e->path, len-2); } - notify->array->entries[notify->array->num_entries] = *e; - notify->array->entries[notify->array->num_entries].private = private; - notify->array->entries[notify->array->num_entries].server = notify->server; + listel = talloc_zero(notify, struct notify_list); + NT_STATUS_HAVE_NO_MEMORY(listel); - if (path) { - notify->array->entries[notify->array->num_entries].path = path; - } + listel->private = private; + listel->callback = callback; + DLIST_ADD(notify->list, listel); - notify->array->num_entries++; + /* ignore failures from sys_notify */ + status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, + sys_notify_callback, listel, + &listel->sys_notify_handle); + if (NT_STATUS_IS_OK(status)) { + talloc_steal(listel, listel->sys_notify_handle); + notify_unlock(notify); + } else { + notify->array->entries[notify->array->num_entries] = *e; + notify->array->entries[notify->array->num_entries].private = private; + notify->array->entries[notify->array->num_entries].server = notify->server; - status = notify_save(notify); + if (path) { + notify->array->entries[notify->array->num_entries].path = path; + } - notify_unlock(notify); + notify->array->num_entries++; - NT_STATUS_NOT_OK_RETURN(status); + status = notify_save(notify); + + notify_unlock(notify); + + NT_STATUS_NOT_OK_RETURN(status); + } if (path) { talloc_free(path); } - listel = talloc(notify, struct notify_list); - NT_STATUS_HAVE_NO_MEMORY(listel); - - listel->private = private; - listel->callback = callback; - DLIST_ADD(notify->list, listel); - return status; } @@ -323,6 +362,8 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + talloc_free(listel); + status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); @@ -397,6 +438,35 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) } +/* + send a notify message to another messaging server +*/ +static void notify_send(struct notify_context *notify, struct notify_entry *e, + const char *path, uint32_t action) +{ + struct notify_event ev; + DATA_BLOB data; + NTSTATUS status; + TALLOC_CTX *tmp_ctx; + + ev.action = action; + ev.path = path; + ev.private = e->private; + + tmp_ctx = talloc_new(notify); + + status = ndr_push_struct_blob(&data, tmp_ctx, &ev, + (ndr_push_flags_fn_t)ndr_push_notify_event); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return; + } + + status = messaging_send(notify->messaging_ctx, e->server, + MSG_PVFS_NOTIFY, &data); + talloc_free(tmp_ctx); +} + /* see if a notify event matches */ @@ -429,35 +499,6 @@ static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, } -/* - send a notify message to another messaging server -*/ -static void notify_send(struct notify_context *notify, struct notify_entry *e, - const char *path, uint32_t action) -{ - struct notify_event ev; - DATA_BLOB data; - NTSTATUS status; - TALLOC_CTX *tmp_ctx; - - ev.action = action; - ev.path = path; - ev.private = e->private; - - tmp_ctx = talloc_new(notify); - - status = ndr_push_struct_blob(&data, tmp_ctx, &ev, - (ndr_push_flags_fn_t)ndr_push_notify_event); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(tmp_ctx); - return; - } - - status = messaging_send(notify->messaging_ctx, e->server, - MSG_PVFS_NOTIFY, &data); - talloc_free(tmp_ctx); -} - /* trigger a notify message for anyone waiting on a matching event */ @@ -472,7 +513,7 @@ void notify_trigger(struct notify_context *notify, return; } - /* this needs to be changed to a log(n) search */ + /* TODO: this needs to be changed to a log(n) search */ for (i=0;iarray->num_entries;i++) { if (notify_match(notify, ¬ify->array->entries[i], path, filter)) { notify_send(notify, ¬ify->array->entries[i], -- cgit From a9cb173f7674d311624c34205f1417b31972d1f2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Apr 2006 04:50:08 +0000 Subject: r14918: cleaner handling of systems without inotify (This used to be commit cf17ff15b15942f0ce068dd0a94b3b565a9b93cb) --- source4/ntvfs/common/notify.c | 57 +++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 595a0f6566..9ea024f2fc 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -267,6 +267,25 @@ static void sys_notify_callback(struct sys_notify_context *ctx, listel->callback(listel->private, ev); } +/* + add an entry to the notify array +*/ +static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e, + const char *path, void *private) +{ + notify->array->entries[notify->array->num_entries] = *e; + notify->array->entries[notify->array->num_entries].private = private; + notify->array->entries[notify->array->num_entries].server = notify->server; + + if (path) { + notify->array->entries[notify->array->num_entries].path = path; + } + + notify->array->num_entries++; + + return notify_save(notify); +} + /* add a notify watch. This is called when a notify is first setup on a open directory handle. @@ -312,33 +331,23 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, DLIST_ADD(notify->list, listel); /* ignore failures from sys_notify */ - status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, - sys_notify_callback, listel, - &listel->sys_notify_handle); - if (NT_STATUS_IS_OK(status)) { - talloc_steal(listel, listel->sys_notify_handle); - notify_unlock(notify); - } else { - notify->array->entries[notify->array->num_entries] = *e; - notify->array->entries[notify->array->num_entries].private = private; - notify->array->entries[notify->array->num_entries].server = notify->server; - - if (path) { - notify->array->entries[notify->array->num_entries].path = path; + if (notify->sys_notify_ctx != NULL) { + status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, + sys_notify_callback, listel, + &listel->sys_notify_handle); + if (NT_STATUS_IS_OK(status)) { + /* if the kernel handler has said it can handle this notify then + we don't need to add it to the array */ + talloc_steal(listel, listel->sys_notify_handle); + goto done; } - - notify->array->num_entries++; - - status = notify_save(notify); - - notify_unlock(notify); - - NT_STATUS_NOT_OK_RETURN(status); } - if (path) { - talloc_free(path); - } + status = notify_add_array(notify, e, path, private); + +done: + notify_unlock(notify); + talloc_free(path); return status; } -- cgit From 416d7b421001d00c4d494fceb4f2d0ab3e30cfaf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Apr 2006 05:54:10 +0000 Subject: r14920: allow a notify backend to separately specify if it has handled the given mask for the current directory and sub-directories. This allows us to setup the less efficient internal handling for subdirectories, while using the kernel inotify service for the current directory if available. It also allows inotify to handle only some of the filter bits, leaving the other filter bits for the user space handler. (This used to be commit 7c3d989fa44c7f57853a825337159f476d7dff80) --- source4/ntvfs/common/notify.c | 61 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 9ea024f2fc..e0d48d2b80 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -290,10 +290,11 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_en add a notify watch. This is called when a notify is first setup on a open directory handle. */ -NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, +NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, void (*callback)(void *, const struct notify_event *), void *private) { + struct notify_entry e = *e0; NTSTATUS status; struct notify_list *listel; char *path = NULL; @@ -304,8 +305,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, status = notify_load(notify); if (!NT_STATUS_IS_OK(status)) { - notify_unlock(notify); - return status; + goto done; } notify->array->entries = talloc_realloc(notify->array, notify->array->entries, @@ -313,18 +313,25 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, notify->array->num_entries+1); if (notify->array->entries == NULL) { - notify_unlock(notify); - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto done; } /* cope with /. on the end of the path */ - len = strlen(e->path); - if (len > 1 && e->path[len-1] == '.' && e->path[len-2] == '/') { - path = talloc_strndup(notify, e->path, len-2); + len = strlen(e.path); + if (len > 1 && e.path[len-1] == '.' && e.path[len-2] == '/') { + e.path = talloc_strndup(notify, e.path, len-2); + if (e.path == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } } listel = talloc_zero(notify, struct notify_list); - NT_STATUS_HAVE_NO_MEMORY(listel); + if (listel == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } listel->private = private; listel->callback = callback; @@ -332,22 +339,31 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e, /* ignore failures from sys_notify */ if (notify->sys_notify_ctx != NULL) { - status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, + /* + 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, &e, sys_notify_callback, listel, &listel->sys_notify_handle); if (NT_STATUS_IS_OK(status)) { - /* if the kernel handler has said it can handle this notify then - we don't need to add it to the array */ talloc_steal(listel, listel->sys_notify_handle); - goto done; } } - status = notify_add_array(notify, e, path, private); + /* if the system notify handler couldn't handle some of the + filter bits, or couldn't handle a request for recursion + then we need to install it in the array used for the + intra-samba notify handling */ + if (e.filter != 0 || e.subdir_filter != 0) { + status = notify_add_array(notify, &e, path, private); + } done: notify_unlock(notify); - talloc_free(path); + if (e.path != e0->path) { + talloc_free(e.path); + } return status; } @@ -483,8 +499,9 @@ static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, const char *path, uint32_t filter) { size_t len; + BOOL subdir; - if (!(filter & e->filter)) { + if (!(filter & e->filter) && !(filter & e->subdir_filter)) { return False; } @@ -498,13 +515,15 @@ static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, return False; } - if (!e->recursive) { - if (strchr(&path[len+1], '/') != NULL) { - return False; - } + /* the filter and subdir_filter are handled separately, allowing a backend + to flexibly choose what it can handle */ + subdir = (strchr(&path[len+1], '/') != NULL); + + if (subdir) { + return (filter & e->subdir_filter) != 0; } - return True; + return (filter & e->filter) != 0; } -- cgit From fa91368fb4ea2c31f6e1b1037f1bd16ef9f3ba98 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Apr 2006 10:12:36 +0000 Subject: r14945: allow the notify backend to be specified per share (This used to be commit 467027e7730a3bc56f152df7e2ec272905e19584) --- source4/ntvfs/common/notify.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index e0d48d2b80..a1f7e80119 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -77,7 +77,7 @@ static int notify_destructor(void *p) */ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, struct messaging_context *messaging_ctx, - struct event_context *ev) + struct event_context *ev, int snum) { char *path; struct notify_context *notify; @@ -110,7 +110,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, messaging_register(notify->messaging_ctx, notify, MSG_PVFS_NOTIFY, notify_handler); - notify->sys_notify_ctx = sys_notify_init(-1, notify, ev); + notify->sys_notify_ctx = sys_notify_init(snum, notify, ev); return notify; } -- cgit From 317c4b81a5edf18eeb7f6358ca5b508e4af80bfd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Apr 2006 13:51:44 +0000 Subject: r14951: - remove unused var 'path' - fix compiler warning metze (This used to be commit 4d7de8b251e006a469adf2793dae422e128844c5) --- source4/ntvfs/common/notify.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index a1f7e80119..318b114efa 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -271,16 +271,12 @@ static void sys_notify_callback(struct sys_notify_context *ctx, add an entry to the notify array */ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e, - const char *path, void *private) + void *private) { notify->array->entries[notify->array->num_entries] = *e; notify->array->entries[notify->array->num_entries].private = private; notify->array->entries[notify->array->num_entries].server = notify->server; - if (path) { - notify->array->entries[notify->array->num_entries].path = path; - } - notify->array->num_entries++; return notify_save(notify); @@ -296,8 +292,8 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, { struct notify_entry e = *e0; NTSTATUS status; + char *tmp_path = NULL; struct notify_list *listel; - char *path = NULL; size_t len; status = notify_lock(notify); @@ -320,11 +316,12 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, /* cope with /. on the end of the path */ len = strlen(e.path); if (len > 1 && e.path[len-1] == '.' && e.path[len-2] == '/') { - e.path = talloc_strndup(notify, e.path, len-2); - if (e.path == NULL) { + tmp_path = talloc_strndup(notify, e.path, len-2); + if (tmp_path == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } + e.path = tmp_path; } listel = talloc_zero(notify, struct notify_list); @@ -356,14 +353,12 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, then we need to install it in the array used for the intra-samba notify handling */ if (e.filter != 0 || e.subdir_filter != 0) { - status = notify_add_array(notify, &e, path, private); + status = notify_add_array(notify, &e, private); } done: notify_unlock(notify); - if (e.path != e0->path) { - talloc_free(e.path); - } + talloc_free(tmp_path); return status; } -- cgit From 127967334fbf3851debacbc0f2574461b542cbad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Apr 2006 10:36:54 +0000 Subject: r14956: change the notify search to be much more efficient by using a per-depth bisection search. This makes the notify_trigger() call log(N) which makes us scale well for large numbers of outstanding notifies (This used to be commit 16fd00925fdbf77e7a403ad501bf6ea429404c76) --- source4/ntvfs/common/notify.c | 250 ++++++++++++++++++++++++++++-------------- 1 file changed, 167 insertions(+), 83 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 318b114efa..0c264de88f 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -51,6 +51,7 @@ struct notify_list { void *private; void (*callback)(void *, const struct notify_event *); void *sys_notify_handle; + int depth; }; #define NOTIFY_KEY "notify array" @@ -192,7 +193,14 @@ static NTSTATUS notify_save(struct notify_context *notify) int ret; TALLOC_CTX *tmp_ctx; - if (notify->array->num_entries == 0) { + /* if possible, remove some depth arrays */ + while (notify->array->num_depths > 0 && + notify->array->depth[notify->array->num_depths-1].num_entries == 0) { + notify->array->num_depths--; + } + + /* we might just be able to delete the record */ + if (notify->array->num_depths == 0) { ret = tdb_delete_bystring(notify->w->tdb, NOTIFY_KEY); if (ret != 0) { return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -200,11 +208,6 @@ static NTSTATUS notify_save(struct notify_context *notify) return NT_STATUS_OK; } - if (notify->array->num_entries > 1) { - qsort(notify->array->entries, notify->array->num_entries, - sizeof(struct notify_entry), notify_compare); - } - tmp_ctx = talloc_new(notify); status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, @@ -271,14 +274,53 @@ static void sys_notify_callback(struct sys_notify_context *ctx, add an entry to the notify array */ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e, - void *private) + void *private, int depth) { - notify->array->entries[notify->array->num_entries] = *e; - notify->array->entries[notify->array->num_entries].private = private; - notify->array->entries[notify->array->num_entries].server = notify->server; - - notify->array->num_entries++; - + int i; + struct notify_depth *d; + struct notify_entry *ee; + + /* possibly expand the depths array */ + if (depth >= notify->array->num_depths) { + d = talloc_realloc(notify->array, notify->array->depth, + struct notify_depth, depth+1); + NT_STATUS_HAVE_NO_MEMORY(d); + for (i=notify->array->num_depths;i<=depth;i++) { + ZERO_STRUCT(d[i]); + } + notify->array->depth = d; + notify->array->num_depths = depth+1; + } + d = ¬ify->array->depth[depth]; + + /* expand the entries array */ + ee = talloc_realloc(notify->array->depth, d->entries, struct notify_entry, + d->num_entries+1); + NT_STATUS_HAVE_NO_MEMORY(ee); + d->entries = ee; + + d->entries[d->num_entries] = *e; + d->entries[d->num_entries].private = private; + d->entries[d->num_entries].server = notify->server; + d->entries[d->num_entries].path_len = strlen(e->path); + d->num_entries++; + + d->max_mask |= e->filter; + d->max_mask_subdir |= e->subdir_filter; + + if (d->num_entries > 1) { + qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare); + } + + /* recalculate the maximum masks */ + d->max_mask = 0; + d->max_mask_subdir = 0; + + for (i=0;inum_entries;i++) { + d->max_mask |= d->entries[i].filter; + d->max_mask_subdir |= d->entries[i].subdir_filter; + } + return notify_save(notify); } @@ -295,6 +337,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, char *tmp_path = NULL; struct notify_list *listel; size_t len; + int depth; status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); @@ -304,15 +347,6 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, goto done; } - notify->array->entries = talloc_realloc(notify->array, notify->array->entries, - struct notify_entry, - notify->array->num_entries+1); - - if (notify->array->entries == NULL) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - /* cope with /. on the end of the path */ len = strlen(e.path); if (len > 1 && e.path[len-1] == '.' && e.path[len-2] == '/') { @@ -324,6 +358,8 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, e.path = tmp_path; } + depth = count_chars(e.path, '/'); + listel = talloc_zero(notify, struct notify_list); if (listel == NULL) { status = NT_STATUS_NO_MEMORY; @@ -332,6 +368,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, listel->private = private; listel->callback = callback; + listel->depth = depth; DLIST_ADD(notify->list, listel); /* ignore failures from sys_notify */ @@ -353,7 +390,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, then we need to install it in the array used for the intra-samba notify handling */ if (e.filter != 0 || e.subdir_filter != 0) { - status = notify_add_array(notify, &e, private); + status = notify_add_array(notify, &e, private, depth); } done: @@ -370,7 +407,8 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) { NTSTATUS status; struct notify_list *listel; - int i; + int i, depth; + struct notify_depth *d; for (listel=notify->list;listel;listel=listel->next) { if (listel->private == private) { @@ -382,6 +420,8 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + depth = listel->depth; + talloc_free(listel); status = notify_lock(notify); @@ -393,22 +433,25 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) return status; } - for (i=0;iarray->num_entries;i++) { - if (notify->server == notify->array->entries[i].server && - private == notify->array->entries[i].private) { + /* we only have to search at the depth of this element */ + d = ¬ify->array->depth[depth]; + + for (i=0;inum_entries;i++) { + if (private == d->entries[i].private && + notify->server == d->entries[i].server) { break; } } - if (i == notify->array->num_entries) { + if (i == d->num_entries) { notify_unlock(notify); return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - if (i < notify->array->num_entries-1) { - memmove(¬ify->array->entries[i], ¬ify->array->entries[i+1], - sizeof(notify->array->entries[i])*(notify->array->num_entries-(i+1))); + if (i < d->num_entries-1) { + memmove(&d->entries[i], &d->entries[i+1], + sizeof(d->entries[i])*(d->num_entries-(i+1))); } - notify->array->num_entries--; + d->num_entries--; status = notify_save(notify); @@ -423,7 +466,7 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) static NTSTATUS notify_remove_all(struct notify_context *notify) { NTSTATUS status; - int i; + int i, depth, del_count=0; if (notify->list == NULL) { return NT_STATUS_OK; @@ -438,19 +481,26 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) return status; } - for (i=0;iarray->num_entries;i++) { - if (notify->server == notify->array->entries[i].server) { - if (i < notify->array->num_entries-1) { - memmove(¬ify->array->entries[i], ¬ify->array->entries[i+1], - sizeof(notify->array->entries[i])*(notify->array->num_entries-(i+1))); + /* we have to search for all entries across all depths, looking for matches + for our server id */ + for (depth=0;deptharray->num_depths;depth++) { + struct notify_depth *d = ¬ify->array->depth[depth]; + for (i=0;inum_entries;i++) { + if (notify->server == d->entries[i].server) { + if (i < d->num_entries-1) { + memmove(&d->entries[i], &d->entries[i+1], + sizeof(d->entries[i])*(d->num_entries-(i+1))); + } + i--; + d->num_entries--; + del_count++; } - i--; - notify->array->num_entries--; } } - - status = notify_save(notify); + if (del_count > 0) { + status = notify_save(notify); + } notify_unlock(notify); @@ -487,61 +537,95 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, talloc_free(tmp_ctx); } -/* - see if a notify event matches -*/ -static BOOL notify_match(struct notify_context *notify, struct notify_entry *e, - const char *path, uint32_t filter) -{ - size_t len; - BOOL subdir; - - if (!(filter & e->filter) && !(filter & e->subdir_filter)) { - return False; - } - - len = strlen(e->path); - - if (strncmp(path, e->path, len) != 0) { - return False; - } - - if (path[len] != '/') { - return False; - } - - /* the filter and subdir_filter are handled separately, allowing a backend - to flexibly choose what it can handle */ - subdir = (strchr(&path[len+1], '/') != NULL); - - if (subdir) { - return (filter & e->subdir_filter) != 0; - } - - return (filter & e->filter) != 0; -} - /* trigger a notify message for anyone waiting on a matching event + + This function is called a lot, and needs to be very fast. The unusual data structure + and traversal is designed to be fast in the average case, even for large numbers of + notifies */ void notify_trigger(struct notify_context *notify, uint32_t action, uint32_t filter, const char *path) { NTSTATUS status; - int i; + int depth; + const char *p, *next_p; status = notify_load(notify); if (!NT_STATUS_IS_OK(status)) { return; } - /* TODO: this needs to be changed to a log(n) search */ - for (i=0;iarray->num_entries;i++) { - if (notify_match(notify, ¬ify->array->entries[i], path, filter)) { - notify_send(notify, ¬ify->array->entries[i], - path + strlen(notify->array->entries[i].path) + 1, - action); + /* loop along the given path, working with each directory depth separately */ + for (depth=0,p=path; + p && depth < notify->array->num_depths; + p=next_p,depth++) { + int p_len = p - path; + int min_i, max_i, i; + struct notify_depth *d = ¬ify->array->depth[depth]; + next_p = strchr(p+1, '/'); + + /* see if there are any entries at this depth */ + if (d->num_entries == 0) continue; + + /* try to skip based on the maximum mask. If next_p is + NULL then we know it will be a 'this directory' + match, otherwise it must be a subdir match */ + if (next_p != NULL) { + if (0 == (filter & d->max_mask_subdir)) { + continue; + } + } else { + if (0 == (filter & d->max_mask)) { + continue; + } + } + + /* we know there is an entry here worth looking + for. Use a bisection search to find the first entry + with a matching path */ + min_i = 0; + max_i = d->num_entries-1; + + while (min_i < max_i) { + struct notify_entry *e; + i = (min_i+max_i)/2; + e = &d->entries[i]; + int cmp = strncmp(path, e->path, p_len); + if (cmp == 0) { + if (p_len == e->path_len) { + max_i = i; + } else { + max_i = i-1; + } + } else if (cmp < 0) { + max_i = i-1; + } else { + min_i = i+1; + } + } + + if (min_i != max_i) { + /* none match */ + continue; + } + + /* we now know that the entries start at min_i */ + for (i=min_i;inum_entries;i++) { + struct notify_entry *e = &d->entries[i]; + if (p_len != e->path_len || + strncmp(path, e->path, p_len) != 0) break; + if (next_p != NULL) { + if (0 == (filter & e->subdir_filter)) { + continue; + } + } else { + if (0 == (filter & e->filter)) { + continue; + } + } + notify_send(notify, e, path + e->path_len + 1, action); } } } -- cgit From cd794e79f999b3b7b639c4fe89ea1af23ed362f6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Apr 2006 11:25:21 +0000 Subject: r14959: allow change notify to be disabled completely using notify:enable=False (This used to be commit 2a8f093105f3047a3697f29aadcc9c48c6ac88e1) --- source4/ntvfs/common/notify.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 0c264de88f..452b8188f0 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -83,6 +83,10 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, char *path; struct notify_context *notify; + if (lp_parm_bool(snum, "notify", "enable", True) != True) { + return NULL; + } + notify = talloc(mem_ctx, struct notify_context); if (notify == NULL) { return NULL; @@ -339,6 +343,11 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, size_t len; int depth; + /* see if change notify is enabled at all */ + if (notify == NULL) { + return NT_STATUS_NOT_IMPLEMENTED; + } + status = notify_lock(notify); NT_STATUS_NOT_OK_RETURN(status); @@ -410,6 +419,11 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) int i, depth; struct notify_depth *d; + /* see if change notify is enabled at all */ + if (notify == NULL) { + return NT_STATUS_NOT_IMPLEMENTED; + } + for (listel=notify->list;listel;listel=listel->next) { if (listel->private == private) { DLIST_REMOVE(notify->list, listel); @@ -552,6 +566,11 @@ void notify_trigger(struct notify_context *notify, int depth; const char *p, *next_p; + /* see if change notify is enabled at all */ + if (notify == NULL) { + return; + } + status = notify_load(notify); if (!NT_STATUS_IS_OK(status)) { return; -- cgit From 26c9cd62118df387d03b1f467fa6bf07cf57d7ec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Apr 2006 11:44:55 +0000 Subject: r14960: don't declare variables mid-function (This used to be commit 4537de9289ce025a240fe46a708434c195138d20) --- source4/ntvfs/common/notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 452b8188f0..a701880701 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -609,9 +609,10 @@ void notify_trigger(struct notify_context *notify, while (min_i < max_i) { struct notify_entry *e; + int cmp; i = (min_i+max_i)/2; e = &d->entries[i]; - int cmp = strncmp(path, e->path, p_len); + cmp = strncmp(path, e->path, p_len); if (cmp == 0) { if (p_len == e->path_len) { max_i = i; -- cgit From 2e894625e7c951b5ee66670124b4bef82a8129d9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 7 Apr 2006 13:15:46 +0000 Subject: r14964: - move sidmap code from ntvfs_common to SAMDB - make ntvfs_common a library - create sys_notify library metze (This used to be commit a3e1d56cf7b688c515f5d6d4d43e0b24c2261d15) --- source4/ntvfs/common/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index a701880701..2d880dd5c4 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -115,7 +115,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, messaging_register(notify->messaging_ctx, notify, MSG_PVFS_NOTIFY, notify_handler); - notify->sys_notify_ctx = sys_notify_init(snum, notify, ev); + notify->sys_notify_ctx = sys_notify_context_create(snum, notify, ev); return notify; } -- cgit From 225d6485eb896bfa50b564aabfe20967edd008e4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 22 May 2006 06:18:40 +0000 Subject: r15797: fixed a notify bug, where a notify_remove() is beyond the current max depth (This used to be commit 2ebcfcc6dadd4a420431c733bb12fe7719057fd6) --- source4/ntvfs/common/notify.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 2d880dd5c4..57cbce3863 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -447,6 +447,11 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) return status; } + if (depth >= notify->array->num_depths) { + notify_unlock(notify); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + /* we only have to search at the depth of this element */ d = ¬ify->array->depth[depth]; -- cgit From 971d30bb201f5c3faff5f575d26882eb79f7955a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 May 2006 07:34:11 +0000 Subject: r15854: more talloc_set_destructor() typesafe fixes (This used to be commit 61c6100617589ac6df4f527877241464cacbf8b3) --- source4/ntvfs/common/notify.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 57cbce3863..222bd7a927 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -63,9 +63,8 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private, /* destroy the notify context */ -static int notify_destructor(void *p) +static int notify_destructor(struct notify_context *notify) { - struct notify_context *notify = talloc_get_type(p, struct notify_context); messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify); notify_remove_all(notify); return 0; -- cgit From 9c66f601f1520a99b9236c32bc9f03a33bd4b2aa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 23 Jul 2006 18:43:07 +0000 Subject: r17206: Add a modular API for share configuration. Commit the classic backwards compatible module which is the default one (This used to be commit a89cc346b9296cb49929898d257a064a6c2bae86) --- source4/ntvfs/common/notify.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 222bd7a927..dbf404d9e6 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -56,6 +56,9 @@ struct notify_list { #define NOTIFY_KEY "notify array" +#define NOTIFY_ENABLE "notify:enable" +#define NOTIFY_ENABLE_DEFAULT True + static NTSTATUS notify_remove_all(struct notify_context *notify); static void notify_handler(struct messaging_context *msg_ctx, void *private, uint32_t msg_type, uint32_t server_id, DATA_BLOB *data); @@ -77,12 +80,13 @@ static int notify_destructor(struct notify_context *notify) */ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, struct messaging_context *messaging_ctx, - struct event_context *ev, int snum) + struct event_context *ev, + struct share_config *scfg) { char *path; struct notify_context *notify; - if (lp_parm_bool(snum, "notify", "enable", True) != True) { + if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) { return NULL; } @@ -114,7 +118,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, messaging_register(notify->messaging_ctx, notify, MSG_PVFS_NOTIFY, notify_handler); - notify->sys_notify_ctx = sys_notify_context_create(snum, notify, ev); + notify->sys_notify_ctx = sys_notify_context_create(scfg, notify, ev); return notify; } -- cgit From 0329d755a7611ba3897fc1ee9bdce410cc33d7f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 30 Aug 2006 11:29:34 +0000 Subject: r17930: Merge noinclude branch: * Move dlinklist.h, smb.h to subsystem-specific directories * Clean up ads.h and move what is left of it to dsdb/ (only place where it's used) (This used to be commit f7afa1cb77f3cfa7020b57de12e6003db7cfcc42) --- source4/ntvfs/common/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index dbf404d9e6..17c6e81c6f 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -32,7 +32,7 @@ #include "db_wrap.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" -#include "dlinklist.h" +#include "lib/util/dlinklist.h" #include "ntvfs/sysdep/sys_notify.h" struct notify_context { -- cgit From af870da6194b47c6cd09445c1e03832d00e951bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Oct 2006 23:32:23 +0000 Subject: r19428: moved tdbutil.c from lib/tdb/common/ to lib/util/util_tdb.c tdbutil.c is Samba specific, so should not be part of the generic tdb library (This used to be commit 979dd24f5e44605fc1603b690913b8c31be7478f) --- source4/ntvfs/common/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 17c6e81c6f..19a60a51a9 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -27,7 +27,7 @@ #include "includes.h" #include "system/filesys.h" #include "lib/tdb/include/tdb.h" -#include "lib/tdb/include/tdbutil.h" +#include "lib/util/util_tdb.h" #include "messaging/messaging.h" #include "db_wrap.h" #include "lib/messaging/irpc.h" -- cgit From 1cd4339b9a2786aa26691ca4f02fa93ab0958b88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Jan 2007 10:52:09 +0000 Subject: r20646: first preparations for cluster enablement. This changes " uint32_t server_id to struct server_id server_id; which allows a server ID to have an node number. The node number will be zero in non-clustered case. This is the most basic hook needed for clustering, and ctdb. (This used to be commit 2365abaa991d57d68c6ebe9be608e01c907102eb) --- source4/ntvfs/common/notify.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 19a60a51a9..13fd44abf0 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -37,7 +37,7 @@ struct notify_context { struct tdb_wrap *w; - uint32_t server; + struct server_id server; struct messaging_context *messaging_ctx; struct notify_list *list; struct notify_array *array; @@ -61,7 +61,7 @@ struct notify_list { static NTSTATUS notify_remove_all(struct notify_context *notify); static void notify_handler(struct messaging_context *msg_ctx, void *private, - uint32_t msg_type, uint32_t server_id, DATA_BLOB *data); + uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); /* destroy the notify context @@ -78,7 +78,7 @@ static int notify_destructor(struct notify_context *notify) talloc_free(). We need the messaging_ctx to allow for notifications via internal messages */ -struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server, +struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, struct messaging_context *messaging_ctx, struct event_context *ev, struct share_config *scfg) @@ -241,7 +241,7 @@ static NTSTATUS notify_save(struct notify_context *notify) handle incoming notify messages */ static void notify_handler(struct messaging_context *msg_ctx, void *private, - uint32_t msg_type, uint32_t server_id, DATA_BLOB *data) + uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { struct notify_context *notify = talloc_get_type(private, struct notify_context); NTSTATUS status; @@ -460,7 +460,7 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) for (i=0;inum_entries;i++) { if (private == d->entries[i].private && - notify->server == d->entries[i].server) { + cluster_id_equal(¬ify->server, &d->entries[i].server)) { break; } } @@ -508,7 +508,7 @@ static NTSTATUS notify_remove_all(struct notify_context *notify) for (depth=0;deptharray->num_depths;depth++) { struct notify_depth *d = ¬ify->array->depth[depth]; for (i=0;inum_entries;i++) { - if (notify->server == d->entries[i].server) { + if (cluster_id_equal(¬ify->server, &d->entries[i].server)) { if (i < d->num_entries-1) { memmove(&d->entries[i], &d->entries[i+1], sizeof(d->entries[i])*(d->num_entries-(i+1))); -- cgit From 98ac70b6a3f7eb48beb86f543f629f77d2aa4549 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 10 Jan 2007 13:25:39 +0000 Subject: r20653: If this is the wrong way to fix the build, I apologize. But these includes are necessary in my environment to get through make. Volker (This used to be commit 47e80da39f27a7e7aa6f85d6333f2d1772292ec9) --- source4/ntvfs/common/notify.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 13fd44abf0..8ba918d8af 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -34,6 +34,7 @@ #include "librpc/gen_ndr/ndr_notify.h" #include "lib/util/dlinklist.h" #include "ntvfs/sysdep/sys_notify.h" +#include "cluster/cluster.h" struct notify_context { struct tdb_wrap *w; -- cgit From f40182cb123c91d4bc8fd3dbf9c3cca615f72c31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Jan 2007 11:58:03 +0000 Subject: r20897: fix compiler warnings metze (This used to be commit 5ac562e1e0e8de03c8bcd083a1822b31667c5e21) --- source4/ntvfs/common/notify.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 8ba918d8af..0ee66a5a41 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -33,6 +33,7 @@ #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" #include "lib/util/dlinklist.h" +#include "ntvfs/common/ntvfs_common.h" #include "ntvfs/sysdep/sys_notify.h" #include "cluster/cluster.h" -- cgit From 2ad79af331ee77a7772a1e7840d3ce613ca051ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 20 Jan 2007 00:49:04 +0000 Subject: r20920: use cluster_tdb_tmp_open() in ntvfs backend code (This used to be commit c9080c54872f107d1e42e77261df50a5d55d294f) --- source4/ntvfs/common/notify.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 0ee66a5a41..2306cfe742 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -85,7 +85,6 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, struct event_context *ev, struct share_config *scfg) { - char *path; struct notify_context *notify; if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) { @@ -97,11 +96,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, return NULL; } - path = smbd_tmp_path(notify, "notify.tdb"); - notify->w = tdb_wrap_open(notify, path, 0, - TDB_SEQNUM, - O_RDWR|O_CREAT, 0600); - talloc_free(path); + notify->w = cluster_tdb_tmp_open(notify, "notify.tdb", TDB_SEQNUM); if (notify->w == NULL) { talloc_free(notify); return NULL; -- cgit From 67f494d72ae33da328504c5e86357c8b755c0053 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 23 Jan 2007 15:06:41 +0000 Subject: r20972: "private" -> "private_data" (This used to be commit 8cbcd3d1cbb0661b1767bb7ace0804cf9a573e34) --- source4/ntvfs/common/notify.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 2306cfe742..5954a7ebe2 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -50,7 +50,7 @@ struct notify_context { struct notify_list { struct notify_list *next, *prev; - void *private; + void *private_data; void (*callback)(void *, const struct notify_event *); void *sys_notify_handle; int depth; @@ -62,7 +62,7 @@ struct notify_list { #define NOTIFY_ENABLE_DEFAULT True static NTSTATUS notify_remove_all(struct notify_context *notify); -static void notify_handler(struct messaging_context *msg_ctx, void *private, +static void notify_handler(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); /* @@ -237,10 +237,10 @@ static NTSTATUS notify_save(struct notify_context *notify) /* handle incoming notify messages */ -static void notify_handler(struct messaging_context *msg_ctx, void *private, +static void notify_handler(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { - struct notify_context *notify = talloc_get_type(private, struct notify_context); + struct notify_context *notify = talloc_get_type(private_data, struct notify_context); NTSTATUS status; struct notify_event ev; TALLOC_CTX *tmp_ctx = talloc_new(notify); @@ -254,8 +254,8 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private, } for (listel=notify->list;listel;listel=listel->next) { - if (listel->private == ev.private) { - listel->callback(listel->private, &ev); + if (listel->private_data == ev.private_data) { + listel->callback(listel->private_data, &ev); break; } } @@ -270,15 +270,15 @@ 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 = listel; - listel->callback(listel->private, ev); + ev->private_data = listel; + listel->callback(listel->private_data, ev); } /* add an entry to the notify array */ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e, - void *private, int depth) + void *private_data, int depth) { int i; struct notify_depth *d; @@ -304,7 +304,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_en d->entries = ee; d->entries[d->num_entries] = *e; - d->entries[d->num_entries].private = private; + d->entries[d->num_entries].private_data = private_data; d->entries[d->num_entries].server = notify->server; d->entries[d->num_entries].path_len = strlen(e->path); d->num_entries++; @@ -334,7 +334,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_en */ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, void (*callback)(void *, const struct notify_event *), - void *private) + void *private_data) { struct notify_entry e = *e0; NTSTATUS status; @@ -375,7 +375,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, goto done; } - listel->private = private; + listel->private_data = private_data; listel->callback = callback; listel->depth = depth; DLIST_ADD(notify->list, listel); @@ -399,7 +399,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, then we need to install it in the array used for the intra-samba notify handling */ if (e.filter != 0 || e.subdir_filter != 0) { - status = notify_add_array(notify, &e, private, depth); + status = notify_add_array(notify, &e, private_data, depth); } done: @@ -412,7 +412,7 @@ done: /* remove a notify watch. Called when the directory handle is closed */ -NTSTATUS notify_remove(struct notify_context *notify, void *private) +NTSTATUS notify_remove(struct notify_context *notify, void *private_data) { NTSTATUS status; struct notify_list *listel; @@ -425,7 +425,7 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) } for (listel=notify->list;listel;listel=listel->next) { - if (listel->private == private) { + if (listel->private_data == private_data) { DLIST_REMOVE(notify->list, listel); break; } @@ -456,7 +456,7 @@ NTSTATUS notify_remove(struct notify_context *notify, void *private) d = ¬ify->array->depth[depth]; for (i=0;inum_entries;i++) { - if (private == d->entries[i].private && + if (private_data == d->entries[i].private_data && cluster_id_equal(¬ify->server, &d->entries[i].server)) { break; } @@ -540,7 +540,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, ev.action = action; ev.path = path; - ev.private = e->private; + ev.private_data = e->private_data; tmp_ctx = talloc_new(notify); -- cgit From a80732cf0010404ef52f9ba05fd6e318461ae375 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 23 Jan 2007 20:57:50 +0000 Subject: r20983: Two no-mem error returns (This used to be commit 79a0cd3a1bbd3d4ef0c335f398fa8bb8e82c8624) --- source4/ntvfs/common/notify.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 5954a7ebe2..91fa8a1d78 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -213,6 +213,7 @@ static NTSTATUS notify_save(struct notify_context *notify) } tmp_ctx = talloc_new(notify); + NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, (ndr_push_flags_fn_t)ndr_push_notify_array); @@ -246,6 +247,10 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data TALLOC_CTX *tmp_ctx = talloc_new(notify); struct notify_list *listel; + if (tmp_ctx == NULL) { + return; + } + status = ndr_pull_struct_blob(data, tmp_ctx, &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); if (!NT_STATUS_IS_OK(status)) { -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/ntvfs/common/notify.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 91fa8a1d78..0d36a20a60 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/ntvfs/common/notify.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 0d36a20a60..0214c39b2d 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -58,7 +58,7 @@ struct notify_list { #define NOTIFY_KEY "notify array" #define NOTIFY_ENABLE "notify:enable" -#define NOTIFY_ENABLE_DEFAULT True +#define NOTIFY_ENABLE_DEFAULT true static NTSTATUS notify_remove_all(struct notify_context *notify); static void notify_handler(struct messaging_context *msg_ctx, void *private_data, @@ -86,7 +86,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, { struct notify_context *notify; - if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) { + if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != true) { return NULL; } -- cgit From 529763a9aa192a6785ba878aceeb1683c2510913 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:24:51 +0100 Subject: r25920: ndr: change NTSTAUS into enum ndr_err_code (samba4 callers) lib/messaging/ lib/registry/ lib/ldb-samba/ librpc/rpc/ auth/auth_winbind.c auth/gensec/ auth/kerberos/ dsdb/repl/ dsdb/samdb/ dsdb/schema/ torture/ cluster/ctdb/ kdc/ ntvfs/ipc/ torture/rap/ ntvfs/ utils/getntacl.c ntptr/ smb_server/ libcli/wrepl/ wrepl_server/ libcli/cldap/ libcli/dgram/ libcli/ldap/ libcli/raw/ libcli/nbt/ libnet/ winbind/ rpc_server/ metze (This used to be commit 6223c7fddc972687eb577e04fc1c8e0604c35435) --- source4/ntvfs/common/notify.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 0214c39b2d..4578dfbf10 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -146,7 +146,7 @@ static NTSTATUS notify_load(struct notify_context *notify) { TDB_DATA dbuf; DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; int seqnum; seqnum = tdb_get_seqnum(notify->w->tdb); @@ -169,11 +169,14 @@ static NTSTATUS notify_load(struct notify_context *notify) blob.data = dbuf.dptr; blob.length = dbuf.dsize; - status = ndr_pull_struct_blob(&blob, notify->array, notify->array, - (ndr_pull_flags_fn_t)ndr_pull_notify_array); + ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array, + (ndr_pull_flags_fn_t)ndr_pull_notify_array); free(dbuf.dptr); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } - return status; + return NT_STATUS_OK; } /* @@ -192,7 +195,7 @@ static NTSTATUS notify_save(struct notify_context *notify) { TDB_DATA dbuf; DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; int ret; TALLOC_CTX *tmp_ctx; @@ -214,11 +217,11 @@ static NTSTATUS notify_save(struct notify_context *notify) tmp_ctx = talloc_new(notify); NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); - status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, - (ndr_push_flags_fn_t)ndr_push_notify_array); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, + (ndr_push_flags_fn_t)ndr_push_notify_array); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } dbuf.dptr = blob.data; @@ -241,7 +244,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { struct notify_context *notify = talloc_get_type(private_data, struct notify_context); - NTSTATUS status; + enum ndr_err_code ndr_err; struct notify_event ev; TALLOC_CTX *tmp_ctx = talloc_new(notify); struct notify_list *listel; @@ -250,9 +253,9 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data return; } - status = ndr_pull_struct_blob(data, tmp_ctx, &ev, + ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); return; } @@ -540,6 +543,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, struct notify_event ev; DATA_BLOB data; NTSTATUS status; + enum ndr_err_code ndr_err; TALLOC_CTX *tmp_ctx; ev.action = action; @@ -548,9 +552,9 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, tmp_ctx = talloc_new(notify); - status = ndr_push_struct_blob(&data, tmp_ctx, &ev, + ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); return; } -- cgit From ca0b72a1fdb7bd965065e833df34662afef0423e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 20:12:00 +0100 Subject: r26003: Split up DB_WRAP, as first step in an attempt to sanitize dependencies. (This used to be commit 56dfcb4f2f8e74c9d8b2fe3a0df043781188a555) --- source4/ntvfs/common/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 4578dfbf10..16cf4e4b54 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -28,7 +28,7 @@ #include "lib/tdb/include/tdb.h" #include "lib/util/util_tdb.h" #include "messaging/messaging.h" -#include "db_wrap.h" +#include "tdb_wrap.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" #include "lib/util/dlinklist.h" -- cgit From 61873ce94c172c801a4831de5550a8e0fe54c5f5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:23 +0100 Subject: r26431: Require ndr_push creators to specify a iconv_convenience context. (This used to be commit 7352206f4450fdf881b95bda064cedd9d2477e4c) --- source4/ntvfs/common/notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 16cf4e4b54..187a349b4b 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -35,6 +35,7 @@ #include "ntvfs/common/ntvfs_common.h" #include "ntvfs/sysdep/sys_notify.h" #include "cluster/cluster.h" +#include "param/param.h" struct notify_context { struct tdb_wrap *w; @@ -95,7 +96,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, return NULL; } - notify->w = cluster_tdb_tmp_open(notify, "notify.tdb", TDB_SEQNUM); + notify->w = cluster_tdb_tmp_open(notify, global_loadparm, "notify.tdb", TDB_SEQNUM); if (notify->w == NULL) { talloc_free(notify); return NULL; -- cgit From e31abef15f7696cf39e9e81307f153da93568e02 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:55 +0100 Subject: r26440: Remove more uses of global_loadparm. (This used to be commit 8858cf39722f192865e531164c72039fd18d7a8d) --- source4/ntvfs/common/notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 187a349b4b..8bbf2d04b3 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -82,6 +82,7 @@ static int notify_destructor(struct notify_context *notify) */ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, struct messaging_context *messaging_ctx, + struct loadparm_context *lp_ctx, struct event_context *ev, struct share_config *scfg) { @@ -96,7 +97,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, return NULL; } - notify->w = cluster_tdb_tmp_open(notify, global_loadparm, "notify.tdb", TDB_SEQNUM); + notify->w = cluster_tdb_tmp_open(notify, lp_ctx, "notify.tdb", TDB_SEQNUM); if (notify->w == NULL) { talloc_free(notify); return NULL; -- cgit From 86dc05e99f124db47f2743d1fc23117a7f5145ab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Jan 2008 22:05:05 -0600 Subject: r26638: libndr: Require explicitly specifying iconv_convenience for ndr_struct_push_blob(). (This used to be commit 61ad78ac98937ef7a9aa32075a91a1c95b7606b3) --- source4/ntvfs/common/notify.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 8bbf2d04b3..ad0a55da79 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -219,7 +219,7 @@ static NTSTATUS notify_save(struct notify_context *notify) tmp_ctx = talloc_new(notify); NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), notify->array, (ndr_push_flags_fn_t)ndr_push_notify_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -554,8 +554,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, tmp_ctx = talloc_new(notify); - ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, - (ndr_push_flags_fn_t)ndr_push_notify_event); + ndr_err = ndr_push_struct_blob(&data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); return; -- cgit From 7d5f0e0893d42b56145a3ffa34e3b4b9906cbd91 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Jan 2008 22:05:13 -0600 Subject: r26639: librpc: Pass iconv convenience on from RPC connection to NDR library, so it can be overridden by OpenChange. (This used to be commit 2f29f80e07adef1f020173f2cd6d947d0ef505ce) --- source4/ntvfs/common/notify.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index ad0a55da79..94d32488eb 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -171,7 +171,8 @@ static NTSTATUS notify_load(struct notify_context *notify) blob.data = dbuf.dptr; blob.length = dbuf.dsize; - ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array, + ndr_err = ndr_pull_struct_blob(&blob, notify->array, lp_iconv_convenience(global_loadparm), + notify->array, (ndr_pull_flags_fn_t)ndr_pull_notify_array); free(dbuf.dptr); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -255,7 +256,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data return; } - ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev, + ndr_err = ndr_pull_struct_blob(data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); -- cgit From 10169a203019445e6d325a5c1559de3c73782237 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 17:54:24 +0100 Subject: Remove more global_loadparm instance.s (This used to be commit a1280252ce924df69d911e597b7f65d8038abef9) --- source4/ntvfs/common/notify.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 94d32488eb..23aa3fb668 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -45,6 +45,7 @@ struct notify_context { struct notify_array *array; int seqnum; struct sys_notify_context *sys_notify_ctx; + struct smb_iconv_convenience *iconv_convenience; }; @@ -107,6 +108,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, notify->messaging_ctx = messaging_ctx; notify->list = NULL; notify->array = NULL; + notify->iconv_convenience = lp_iconv_convenience(lp_ctx); notify->seqnum = tdb_get_seqnum(notify->w->tdb); talloc_set_destructor(notify, notify_destructor); @@ -171,7 +173,7 @@ static NTSTATUS notify_load(struct notify_context *notify) blob.data = dbuf.dptr; blob.length = dbuf.dsize; - ndr_err = ndr_pull_struct_blob(&blob, notify->array, lp_iconv_convenience(global_loadparm), + ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->iconv_convenience, notify->array, (ndr_pull_flags_fn_t)ndr_pull_notify_array); free(dbuf.dptr); @@ -220,7 +222,7 @@ static NTSTATUS notify_save(struct notify_context *notify) tmp_ctx = talloc_new(notify); NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), notify->array, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->iconv_convenience, notify->array, (ndr_push_flags_fn_t)ndr_push_notify_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -256,7 +258,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data return; } - ndr_err = ndr_pull_struct_blob(data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, + ndr_err = ndr_pull_struct_blob(data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -555,7 +557,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, tmp_ctx = talloc_new(notify); - ndr_err = ndr_push_struct_blob(&data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); + ndr_err = ndr_push_struct_blob(&data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); return; -- cgit From c15ffa27cb3a1cadbbf06d564146c1ab8dec952b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 01:19:53 +0200 Subject: Explicitly require event context to be specified. (This used to be commit a95a71fe45ef6a578569931a7c38061783d07db3) --- source4/ntvfs/common/notify.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/ntvfs/common/notify.c') diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 23aa3fb668..9055d6ece3 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -93,6 +93,10 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, return NULL; } + if (ev == NULL) { + return NULL; + } + notify = talloc(mem_ctx, struct notify_context); if (notify == NULL) { return NULL; -- cgit